AlphaPress Publishing
P.O. Box 5942 Albany, NY 12205
Tel: 518-250-3890
Email: alphapress@hotmail.com  


  
Click to buy this book from Amazon

Section Menu 

News

Pindaro is now working on a comprehensive book on SQL Server 2014.  For any comments you can email the author at alphapress@hotmail.com.

  

 

 

How to Use the IN operator with Numeric data

To contact the author click here

This article is from the book "Access 2007 Pure SQL

To download the sample database click here


The IN operator with numeric data

Create a report of products based on prices

Discussion:

In this scenario, we need to produce a business report that lists products from our product catalog with the following prices: 15, 19, 22, 23, and 42.  Since the numbers are not sequential, we cannot use the BETWEEN operator to get our results.  We can, however, use the IN operator to produce the report almost as fast.  Note that when we employ IN with numbers, we do not use quotes. 

Code:

SELECT productname, quantityperunit, productunitprice

FROM products

WHERE productunitprice in (15, 19, 22, 23, 42)
 

Result: