[thelist] An sql problem

Philippe Jadin philippe.jadin at 123piano.com
Fri May 4 15:01:26 CDT 2001


I'm facing a stupid problem in sql, and I thought someone could help here :

I have a table with those :

ID | ref | cat | blabla...

I'd like to add "next" and "previous" buttons on a page displaying a
particlar row of the table.

What sql sould I use to get the next and previous id's based on a particular
"id", and ordered in this case by "ref"? I obviously can't say next = id+1
and previous=id-1. Because Id's are not +1 for each row.

I would like to have somethin like this

22|po1|1 ->the previous id
51|po2|1 -> the current id
12|po3|1 ->the next id

Sorry, I can't find a solution for this one.

I'm using mysql

Thank you


More information about the thelist mailing list