I have a table with 3 columns as follows:

lower upper id
12 20 100
100 150 200


I want to select range of numbers based on lower and upper column.
For example I want to display numbers between 12 to 20 or from 100 to 150.
How to do it. thanks in advance.

Recommended Answers

All 2 Replies

Hi, you can use math comparison operators to select from a range of values, you can add an OR to the statement below to select from an additional range.

SELECT
*
FROM
TableName
WHERE 
([lower] >= 12
 AND 
[upper] <= 20)
OR
([lower] >= 100
 AND 
[upper] <= 150)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.