List comparison operators

Use list comparison operators to compare a value to a list of values.

Conditions using list comparison operators use the binary comparison operators with the logical operators (ANY, ALL, IN, or NOT IN).

The syntax of a list comparison expression is either:

expression comparison_operator { ANY | ALL } ( expression,... )

or

expression [ NOT ] IN ( expression,... )

If you use the ANY keyword, the list comparison condition evaluates to TRUE if the comparison of the left hand expression to the right hand expressions returns TRUE for any of the values. If you use the ALL keyword, the list comparison condition evaluates to TRUE if the comparison of the left hand expression to the right hand expressions returns TRUE for all of the values.

An IN comparison returns the same results as the =ANY comparison. A NOT IN comparison returns the same results as the <>ALL comparison.

Restriction: The ANY and ALL operators are not supported in subqueries.

Example

The following query returns the rows in which Severity - 1 is equal to the value of Old_Severity or the number 5.

select * from mystatus where Severity - 1 IN (Old_Severity, 5)