List:General Discussion« Previous MessageNext Message »
From:David Felio Date:July 22 2002 8:21pm
Subject:Re: Surrounding Rows
View as plain text  
It isn't in one statement, but what about, after you get your zip code

select * from table where zip < yourzip order by zip desc limit 5
select * from table where zip > yourzip order by zip limit 5


On Monday, July 22, 2002, at 12:53  PM, Jan Peuker wrote:

> Hi,
>
> sorry for my bad earlier explanation.
> What I want to do is, select the 10(say, a value) nearest values to a given
> number. The easiest way would be "near 5" shows 1..10. The problem is, the
> number should affect rows, not values, because values are not unique nor 
> in
> order. What I want to do is a query like "SELECT code FROM zip WHERE
> zip=12345 SURROUND 5,5" or "SURROUND 10". At the moment, I create a new
> table w/ an autoincrement and do a select...insert, then I select first the
> id and then id-5 and id+5. This a a) very slow and redundant b) afaik not
> very safe.
> Thanks a lot,

David Felio
Software Developer
Information Network of Arkansas
http://www.AccessArkansas.org

Thread
Surrounding RowsJan Peuker22 Jul
  • Re: Surrounding RowsGurhan Ozen22 Jul
  • Re: Surrounding RowsJan Peuker22 Jul
    • Re: Surrounding RowsDavid Felio22 Jul
    • RE: Surrounding RowsGordon22 Jul
    • Re: Surrounding RowsDan Nelson22 Jul
  • Re: Surrounding RowsGurhan Ozen22 Jul
  • Re: Surrounding RowsJan Peuker23 Jul
    • Re: Surrounding RowsDan Nelson23 Jul