Solved

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

Posted on 2007-04-06
2
981 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Select Query help 3 31
Using a SELECT statement inside of a CASE 5 16
SQL Inner Join Vs SubQueries 9 25
SQL Date Retrival 7 30
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now