Using the IN comparison predicate
What cities are in the Chicago, New York, and New Orleans districts?
SELECT hq_city, hq_state, district FROM aroma.market WHERE district IN ('Chicago', 'New York', 'New Orleans');
|New Orleans||LA||New Orleans|
|New York||NY||New York|
A simple condition can be expressed with the following SQL comparison predicates:
|BETWEEN expression1 AND expression2|
|IS NOT NULL|
|SOME or ANY|
Examples of the ALL, SOME or ANY, and EXISTS predicates are presented in Part 5 of this series.
For syntax descriptions and examples of all these predicates, as well as detailed definitions of simple and complex expressions, refer to the SQL Reference Guide .
The example query lists all the cities in the Chicago, New York, and New Orleans districts. It could also be written with the equals comparison operator (=) and a set of OR conditions:
WHERE district = 'Chicago' OR district = 'New York' OR district = 'New Orleans'
Strive to write logical sets of conditions that are simple, easy to understand, and easy to maintain. Always clarify the logical structure of your compound conditions with ample white space, define logical blocks by indentation, and force evaluation precedence with parentheses.