A search condition is a condition used to select rows. Only those rows are selected which return the truth value true for the specified search condition. Search conditions can occur in a number of SQL statements which allow selection of rows in WHERE, HAVING or ON clauses. They can also occur in a check constraint (see "Integrity constraint") or in a case expression (see "CASE expression").
A search condition comprises predicates (logical expressions) which can be linked by the logical operators AND, OR or NOT.
A search condition is evaluated by first evaluating the predicates and then applying the logical operators to the results. The usual precedence rules apply for evaluation: NOT takes precedence over AND, which takes precedence over OR. Parentheses can be used to influence the evaluation sequence.
A search condition returns the truth value true, false or unknown.
AND Operand2 | true | false | unknown |
true | true | false | unknown |
false | false | false | false |
unknown | unknown | false | unknown |
Table 32: Truth values for AND operations
OR Operand2 | true | false | unknown |
true | true | true | true |
false | true | false | unknown |
unknown | true | unknown | unknown |
Table 33: Truth values for OR operations
NOT | |
true | false |
false | true |
unknown | unknown |
Table 34: Truth values with NOT