Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-04-06
2
Medium Priority
?
991 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 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

604 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