Relational-Operator Condition
A relational operator compares two expressions quantitatively.
For a list of the supported relational operators and their descriptions, see Relational Operator.
The following examples show some relational-operator conditions:
city[1,3] = 'San'
o.order_date > '6/12/98'
WEEKDAY(paid_date) = WEEKDAY(CURRENT- (31 UNITS DAY))
YEAR(ship_date) < YEAR (TODAY)
quantity <= 3
customer_num <> 105
customer_num != 105
Operands in relational operator conditions cannot have UNKNOWN or NULL values. If an expression within the condition has an UNKNOWN value because it references an uninitialized variable, the database server raises an exception.
Conditions testing for NULL values
If any
expression within the condition evaluates to NULL, the condition cannot
be true, unless you are explicitly testing for NULL by using the IS
NULL operator. For example, if the paid_date column has a
NULL value, then neither of the following queries can retrieve that
row:
SELECT customer_num, order_date FROM orders
WHERE paid_date = '';
SELECT customer_num, order_date FROM orders
WHERE NOT (paid_date !='');
You must use the
IS NULL operator to test for a NULL value, as the next example shows.
SELECT customer_num, order_date FROM orders
WHERE paid_date IS NULL;
The IS NULL operator and its
logical inverse, the IS NOT NULL operator, are described in IS NULL and IS NOT NULL Conditions.