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 parentheses. The following example 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.9900 18 inch teddy bear 11.9900 8 inch teddy bear 5.9900 Bird bean bag toy 3.4900 Fish bean bag toy 3.4900 Rabbit bean bag toy 3.4900 Raggedy Ann 4.9900
The SELECT statement retrieves all products made by vendor DLL01 and vendor BRS01. The IN |
Get Sams Teach Yourself SQL in 10 Minutes, Second 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.