Search Condition (search_condition)

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.

Examples

SQL Tutorial, Conditions: Comparison, AND, OR, BETWEEN, IN, Arithmetic Operations, Negative Conditions: NOT

Explanation

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.

NOT

X

NOT(x)

true

false

false

true

undefined

undefined

x AND y

x                        y

false

undefined

true

false

false

false

false

undefined

false

undefined

undefined

true

false

undefined

true

x OR y

x                        y

false

undefined

true

false

false

undefined

true

undefined

undefined

undefined

true

true

true

true

true

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.