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 y1, y2, ..., yn.

Model table: customer

Which customers are customers?

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

TITLE

NAME

Comp

DATASOFT

Comp

TOOLware