Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 992
  • Last Modified:

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

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
cool12399
Asked:
cool12399
1 Solution
 
ophoCommented:
Should be:

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

--Steve
0
 
cool12399Author Commented:
Ah excellent! perfect, thanks! :) It saves me a lot of programming! ;)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now