DB2 Version 9.7 for Linux, UNIX, and Windows

Basic predicate

Read syntax diagramSkip visual syntax diagram
>>-+-expression--+- = ------+--expression------------+---------><
   |             |      (1) |                        |   
   |             +- <> -----+                        |   
   |             +- < ------+                        |   
   |             +- > ------+                        |   
   |             |      (1) |                        |   
   |             +- <= -----+                        |   
   |             |      (1) |                        |   
   |             '- >= -----'                        |   
   '-row-value-expression-- = --row-value-expression-'   

Notes:
  1. The following forms of the comparison operators are also supported in basic and quantified predicates: ^=, ^<, ^>, !=, !<, and !>. In code pages 437, 819, and 850, the forms ¬=, ¬<, and ¬> are supported. All of these product-specific forms of the comparison operators are intended only to support existing SQL statements that use these operators, and are not recommended for use when writing new SQL statements.

A basic predicate compares two values or compares a set of values with another set of values.

When a single expression is specified on the left side of the operator, another expression must be specified on the right side. The data types of the corresponding expressions must be compatible. The value of the expression on the left side is compared with the value of the expression on the right side. If the value of either operand is null, the result of the predicate is unknown. Otherwise the result is either true or false.

When a row-value-expression is specified on the left side of the operator and another row-value-expression is specified on the right side of the operator, each row-value-expression must have the same number of value expressions. The data types of the corresponding expressions for each row-value-expression must be compatible. The value of each expression on the left side is compared with the value of its corresponding expression on the right side.

The result of the predicate is:
  • True if all pairs of corresponding value expressions evaluate to true.
  • False if any one pair of corresponding value expressions evaluates to false.
  • Otherwise, unknown (that is, if at least one comparison of corresponding value expressions is unknown because of a null value and no pair of corresponding value expressions evaluates to false).
Predicate
Is True If and Only If...
x = y
x is equal to y
x <> y
x is not equal to y
x < y
x is less than y
x > y
x is greater than y
x >= y
x is greater than or equal to y
x <= y
x is less than or equal to y
Examples:
   EMPNO='528671'  
   SALARY < 20000 
   PRSTAFF <> :VAR1
   SALARY > (SELECT AVG(SALARY) FROM EMPLOYEE)