Using the IN Operator

The IN operator is used to specify a range of conditions, any of which can be matched. IN takes a comma-delimited list of valid values, all enclosed within parenthesis. The following input demonstrates this:

SELECT prod_name, prod_price
FROM Products
WHERE vend_id  IN ('DLL01','BRS01')
ORDER BY prod_name;
prod_name                prod_price
-------------------      ----------
12 inch teddy bear       8.99
18 inch teddy bear       11.99
8 inch teddy bear        5.99
Bird bean bag toy        3.49
Fish bean bag toy        3.49
Rabbit bean bag toy      3.49
Raggedy Ann              4.99

The SELECT statement retrieves all products made by vendor DLL01 and vendor BRS01. The IN operator is followed by a comma- delimited list of valid values, and the entire list must be enclosed within parenthesis. ...

Get Sams Teach Yourself SQL in 10 Minutes 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.