A search condition (search_condition) links statements that can be true, false, or undefined. Rows in a table may be found that fulfill several conditions that are linked with AND or OR.
Syntax
<search_condition> ::= <boolean_term> | <search_condition> OR <boolean_term> <boolean_term> ::= <boolean_factor> | <boolean_term> AND <boolean_factor> <boolean_factor> ::= [NOT] <predicate> | [NOT] (<search_condition>)
In the syntax element boolean_factor, the Boolean values (BOOLEAN) to be linked or their negation (NOT) are determined.
SQL Tutorial, Conditions: Comparison, AND, OR, BETWEEN, IN, Arithmetic Operations, Negative Conditions: NOT
Predicates in a WHERE clause are applied to the specified row or a group of rows in a table formed with the GROUP clause (see: Table Expression (table_expression). The results are linked using the specified Boolean operators (AND, OR, NOT).
If no parentheses are used, the precedence of the operators is as follows: NOT has a higher precedence than AND and OR. AND has a higher precedence than OR. Operators with the same precedence are evaluated from left to right.
X |
NOT(x) |
---|---|
True |
False |
False |
True |
Undefined |
Undefined |
x AND y |
False |
Undefined |
True |
False |
False |
False |
False |
Undefined |
False |
Undefined |
Undefined |
True |
False |
Undefined |
True |
x OR y |
False |
Undefined |
True |
False |
False |
Undefined |
True |
Undefined |
Undefined |
Undefined |
True |
True |
True |
True |
True |
Note
A specific form of search condition is required for the SQL Optimizer to be able to determine the most efficient search strategy. For more information, see Concepts of the Database, Search Conditions.