Solved

How to 'select' specific values as a range in SQL?

Posted on 2007-04-06
2
988 Views
Last Modified: 2008-01-09
Hi, not sure if this is the correct category, but I want/would like to know how to create a where clause
whereby it selects values based on a 'range' or a 'set' of values.

I.e., say I have a set of products from 1-100. Is there anyway to do something like:

"Select * from productsTable where productRangeID is in {1,3,5,18,22,30,100}"

*instead* of having to do something like:

Select * from productsTable where (productRangeID ='1' OR productRangeID ='3' OR productRangeID ='5' ... etc, etc)?

Thanks!
0
Comment
Question by:cool12399
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
opho earned 500 total points
ID: 18868092
Should be:

Select * from productsTable where productRangeID in(1,3,5,18,22,30,100)

--Steve
0
 
LVL 10

Author Comment

by:cool12399
ID: 18868492
Ah excellent! perfect, thanks! :) It saves me a lot of programming! ;)
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question