mysql fetch next previous record
(SELECT * FROM zip WHERE id > 26 ORDER BY id ASC LIMIT 1)
UNION
(SELECT * FROM zip WHERE id = 26 ORDER BY id DESC LIMIT 1)
UNION
(SELECT * FROM zip WHERE id < 26 ORDER BY id DESC LIMIT 1)
order by id
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
The other alternative for the above query is posted below. its much better and simpler then the one given above.
Its simple to use. Just one lined.
select id from zip_code where id = (select min(id) from zip_code where id > 26) || id = (select max(id) from zip_code where id < 26) || id = 26
any other post regarding next previous select query is much appreciated…
The other alternative for the above query is posted below. its much better and simpler then the one given above.
Its simple to use. Just one lined.
select id from zip_code where id = (select min(id) from zip_code where id > 26) || id = (select max(id) from zip_code where id < 26) || id = 26