SQL Primer: Using Where . . . In


This example shows use of the WHERE . . . IN clause to return only the records from the Products2 table belonging to a given set of product types. Click on any of the following, and see the result set and SQL source below.

Camping   |   Climbing   |   Clothing

ProductType ProductCode ProductName UnitPrice
Carabiner Climbing Basic Black $ 14
Carabiner Climbing Black Diamond Quicksilver II $ 9
Carabiner Climbing Gold-Series Locking D $ 7
Carabiner Climbing Petzl Spirit $ 13
Crampon Climbing Edgehugger $ 145
Crampon Climbing Glory Grip $ 149
Crampon Climbing Venus $ 99
Crampon Climbing Wafflestomper $ 109
Harness Climbing Black Diamond Alpine Bod $ 29
Harness Climbing Black Diamond Bod $ 32
Harness Climbing El Capitan $ 52
Harness Climbing Petzl Mercury $ 72
RockShoes Climbing Gibralter $ 150
RockShoes Climbing Morro $ 84
RockShoes Climbing Plymouth $ 125
RockShoes Climbing Tuscany $ 124

The SQL Source of the Recordset is as follows:

SELECT DISTINCT ProductType, ProductCode, ProductName, UnitPrice FROM Products2 WHERE ProductType IN ('Carabiner','Crampon','Harness','RockShoes') ORDER BY ProductType, ProductCode

Go Top   |   Return to DB101 ADO Samples