943,521 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Marked Solved
  • Views: 1675
  • MS SQL RSS
Jul 28th, 2008
0

lower and upper limit problem

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ansari.wajid is offline Offline
47 posts
since Aug 2007
Jul 29th, 2008
0

Re: lower and upper limit problem

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.
MS SQL Syntax (Toggle Plain Text)
  1. SELECT
  2. *
  3. FROM
  4. TableName
  5. WHERE
  6. ([lower] >= 12
  7. AND
  8. [upper] <= 20)
  9. OR
  10. ([lower] >= 100
  11. AND
  12. [upper] <= 150)
Reputation Points: 13
Solved Threads: 3
Newbie Poster
RipperJT is offline Offline
23 posts
since Jan 2007
Jul 30th, 2008
0

Re: lower and upper limit problem

Thanks buddy
Reputation Points: 10
Solved Threads: 0
Light Poster
ansari.wajid is offline Offline
47 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Matching values present in my work DB in my Master DB
Next Thread in MS SQL Forum Timeline: Checking if combobox chosen value exists in Master DB





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC