IBM Books

SQL Reference


Search Conditions

 
search-condition
 
|--+------+---+-predicate----------+---------------------------->
   '-NOT--'   '-(search-condition)-'
 
      .-----------------------------------------------------.
      V                                                     |
>--------+-----------------------------------------------+--+---|
         '--+-AND-+---+------+---+-predicate----------+--'
            '-OR--'   '-NOT--'   '-(search-condition)-'
 

A search condition specifies a condition that is "true," "false," or "unknown" about a given row.

The result of a search condition is derived by application of the specified logical operators (AND, OR, NOT) to the result of each specified predicate. If logical operators are not specified, the result of the search condition is the result of the specified predicate.

AND and OR are defined in Table 14, in which P and Q are any predicates:

Table 14. Truth Tables for AND and OR
P Q P AND Q P OR Q
True True True True
True False False True
True Unknown Unknown True
False True False True
False False False False
False Unknown False Unknown
Unknown True Unknown True
Unknown False False Unknown
Unknown Unknown Unknown Unknown

NOT(true) is false, NOT(false) is true, and NOT(unknown) is unknown.

Search conditions within parentheses are evaluated first. If the order of evaluation is not specified by parentheses, NOT is applied before AND, and AND is applied before OR. The order in which operators at the same precedence level are evaluated is undefined to allow for optimization of search conditions.

Figure 12. Search Conditions Evaluation Order

Figure 00001126 not displayed.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]