>> Mysql 4
>> 
>> I have a frustrating case here, a list of numbers, say, 0 through 30,000 or
>> so, however, there are gaps in the numbers, so not purely sequential.
>> 
>> I am faced with selecting one record from the dataset, that's simple,
>> however, before that select, I need to make sure the record is there, and if
>> it is not, find the one either just before it, or just after it.  Whichever
>> is closest.  If they are the same, lean on either one, I don't really care.
>> 
>> Any suggestion on this one would be appreciated, I can do this with 3
>> separate queries, but that is taking too long, since I have to do this with
>> two separate datasets and shove this all back out a browser to the user.
> 
> Clearing this up a little, I have data like this:
> 
> 3, 4, 5, 8, 9, 10
> If I am looking for 6, it is not there, I want back 5 and 8, in this case, 5
> is closest, so I would like 5 back, but both are ok, as I can use server
> side code to determine the closest.

I am thinking UNION and two SQL queries would do this, how is UNION
optimized, is it more or less the same as running two selects?
-- 
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
<http://www.newgeo.com>                     Novato, CA U.S.A.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to