Chapter 14. The [NOT] IN() Predicate

THE IN() PREDICATE IS very natural. It takes a value and sees whether that value is in a list of comparable values. Standard SQL allows value expressions in the list, or for you to use a query to construct the list. The syntax is:

<in predicate> ::=
<row value constructor> [NOT] IN <in predicate value>

<in predicate value> ::=
   <table subquery> | (<in value list>)

<in value list> ::=
   <row value expression> { <comma> <row value expression> }...

The expression <row value constructor> NOT IN <in predicate value> has the same effect as NOT (<row value constructor> IN <in predicate value>). This pattern for the use of the keyword NOT is found in most of the other predicates.

The expression <row value constructor> ...

Get Joe Celko's SQL for Smarties, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.