Predicates

A predicate specifies a condition that is true, false, or unknown about a given row or group.

The types of predicates are:

Read syntax diagram
>>-+-basic predicate------+------------------------------------><
   +-quantified predicate-+   
   +-BETWEEN predicate----+   
   +-DISTINCT predicate---+   
   +-EXISTS predicate-----+   
   +-IN predicate---------+   
   +-LIKE predicate-------+   
   +-NULL predicate-------+   
   '-XMLEXISTS predicate--'   

The following rules apply to predicates of any type:

  • Predicates are evaluated after the expressions that are operands of the predicate.
  • All values that are specified in the same predicate must be compatible.
  • Except for the EXISTS predicate, a subquery in a predicate must specify a single column unless the operand on the other side of the comparison operator is a fullselect.
  • The value of a host variable can be null (that is, the variable can have a negative indicator variable).
  • The CCSID conversion of operands of predicates that involve two or more operands is done according toConversion rules for comparisons.
  • Use of an XML value is limited to the NULL or XMLEXISTS predicates.

Row-value-expression: The operand of several predicates (basic, quantified, DISTINCT, and IN) can be a row-value-expression:

Read syntax diagram
     .-,----------.     
     V            |     
>>-(---expression-+-)------------------------------------------><

A row-value-expression returns a single row that consists of one or more column values. The values can be specified as a list of expressions. The number of columns that are returned by the row-value-expression is equal to the number of expressions that are specified in the list.

Other predicate examples: In addition to the examples of predicates in the following topics, see information on distinct type comparisons in Assignment and comparison, which contains several examples of predicates that use distinct types.Distinct type comparisons, which contains several examples of predicates that use distinct types.