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
Boot Clothing Dunes $ 98
Boot Clothing Everglades $ 98
Boot Clothing Rockies $ 78
Boot Clothing Sierras $ 87
Pants Clothing Men's 8-pocket conversion pants $ 46
Pants Clothing Unisex drawstring pants $ 48
Pants Clothing Unisex hiking pants $ 55
Pants Clothing Women's 4-pocket pants $ 32
Parka Clothing Alpine $ 188
Parka Clothing Campos $ 250
Parka Clothing Crystal $ 125
Parka Clothing Sahara $ 114
Shirt Clothing Men's button-down $ 42
Shirt Clothing Men's loose weave polo $ 45
Shirt Clothing Unisex long-sleeve button-down $ 75
Shirt Clothing Women's woven tee $ 29

The SQL Source of the Recordset is as follows:

SELECT DISTINCT ProductType, ProductCode, ProductName, UnitPrice FROM Products2 WHERE ProductType IN ('Boot','Pants','Parka','Shirt') ORDER BY ProductType, ProductCode

Go Top   |   Return to DB101 ADO Samples