Comparison predicate 

A comparison predicate specifies a comparison between two values or lists of values.

Syntax

<comparison predicate> ::= <expression> <comp op> <expression>
| <expression> <comp op> <subquery>
| <expression list> <equal or not> (<expression list>)
| <expression list> <equal or not> <subquery>

expression, expression list, subquery

The following operators are available for comparing two values:
<, >, <>, !=, =, <=, >= (
comp op)

Value lists can only be compared with the = and <> operators ( equal or not).

Explanation

The subquery must supply a result table (see result table name) that contains the same number of columns as the number of values on the left-hand side of the operator. The result table may contain no more than one row.

The list of values specified to the right of the equal or not operator ( expression list ) must contain the same number of values as specified in the value list in front of the equal or not operator.

The JOIN predicate is a special case.

Comparing two values

Let x be the result of the first expression and y the result of the second expression or of the subquery.

Comparing two value lists

If a value list ( expression list ) is specified on the left of the comparison operator equal or not , x is the value list that comprises the results of the values x1, x2, ..., xn in this list. y is the result of the subquery or the result of the second value list. A value list y consists of the results of the values y 1 , y 2 , ..., yn.

Model table: customer

Which customers are customers?

SELECT title, name FROM customer
WHERE title = 'Comp'

TITLE

NAME

Comp

DATASOFT

Comp

TOOLware