Search conditions are used in:
- WHERE and HAVING clauses to qualify the selection of rows and groups respectively
- CHECK clauses to define sets of acceptable values
- CASE expressions to conditionally return different values
- CASE and IF statements to control conditional execution in a routine or trigger
- WHILE and REPEAT statements to control conditional iteration in a routine or trigger
- the WHEN clause of a trigger to control conditional execution of the trigger action.
A search condition is built from one or more predicates linked by the logical operators AND and OR and qualified if desired by the operator NOT.
The general syntax of a search condition is:
Search conditions enclosed in parentheses may be used as part of more complex search condition constructions. A search condition is evaluated as follows:
- Conditions in parentheses are evaluated first.
- Within the same level of parentheses, NOT is applied before AND, AND is applied before OR.
- Operators at the same precedence level are applied in an order determined by internal optimization routines.
The result of a search condition is evaluated by combining the results of the component predicates. Each predicate evaluates to true, false or unknown, truth tables are shown in Truth Tables.
WHERE and HAVING clauses select the set of values for which the search condition evaluates to true. CHECK clauses define the set of values for which the search condition does not evaluate to false, i.e. is either true or unknown.
The WHERE condition determines which rows to select, for example:SELECT * FROM customer_details WHERE country_code = 'SE'
The HAVING clause restricts the selection of groups. A HAVING clause may use a set function on the left-hand side of a comparison.
This section summarizes standard compliance concerning search conditions.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40