Thread: find a record in range of a number

find a record in range of a number

From
larry postgres
Date:
Hi ..I have done search but cannot find situation that fits. 

I need to do a search or select if you will on a table that contains over 150,000 records.   Within this table there are 2 columns I am interested in.  One is low_number and other is high_number.  I need to find the record(s) that these two columns are in range of a number passed to it through the select statement.

Example:

I want to do a search for all records that the number 301 falls between the low_number and high_number in that same, particular record.

I have in the column low_number of a record the number 280 and in the high_number column I have the number 310.  I am doing a search for all the records that the number 301 will be in range of for the columns low_number and high_number in each particular record.

Since I have passed the number 301 to the select statment. It should return to me the record number that has the values for the low_numbe r at 280 and high_number 310.

I have tried to use RANGE and BETWEEN but they also return records out of range.

Can anyone point me in right direction?

Any help much appreciated.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: find a record in range of a number

From
Michael Fuhr
Date:
On Tue, Feb 21, 2006 at 02:58:26PM -0800, larry postgres wrote:
> Since I have passed the number 301 to the select statment. It
> should return to me the record number that has the values for the
> low_number at 280 and high_number 310.
>
> I have tried to use RANGE and BETWEEN but they also return records
> out of range.

Could you post an example table (CREATE TABLE and INSERT statements)
and some of the queries you've tried?  Somebody will undoubtedly
give an answer, but it's a good idea to learn why things that don't
work don't work.  If we could see what you're doing then we could
provide that explanation.

How did you use RANGE?  I see nothing about it in the documentation
except in the "SQL Key Words" appendix.

--
Michael Fuhr