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.
<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.
Predicates in a WHERE clause are applied to the specified row or a group of rows in a table formed with the GROUP clause. 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 |
SELECT hno, type,
price
FROM room
WHERE price*7 < 500 AND type = 'single'
Displaying the hotels whose weekly price for a single room is below 500.00 euro
HNO |
TYPE |
PRICE |
20 |
single |
70 |
30 |
single |
45 |
100 |
single |
60 |
110 |
single |
70 |