March 2001
Intermediate to advanced
640 pages
14h 9m
English
Earlier, when you were looking at multiple comparisons with AND and OR, you ran a query to find products whose product names matched one of several values. This is the query:
select ProductName, UnitPrice
from Products
where ProductName = 'Konbu'
or ProductName = 'Cream Cheese'
or ProductName = 'Tofu'
or ProductName = 'Pavlova'
The IN operator allows you to compress the four conditions into a single condition like this:
select ProductName, UnitPrice
from Products
where ProductName in
('Konbu', 'Cream Cheese', 'Tofu', 'Pavlova')
Both forms of the query return the same results, and they are identically processed by the server. The second form with IN is more compact and easier to read.
In combination ...
Read now
Unlock full access