[BNM] Moving to next record in MySQL
David Pashley
david at davidpashley.com
Thu May 1 11:13:28 BST 2008
On May 01, 2008 at 10:27, delarge praised the llamas by saying:
> Hi hey yo
>
> I wondered if there is a way to do this in MySQL...
> Say I pick the latest id like SELECT * etc. LIMIT 1
>
> and that has an id of 1325 for example...
> so we have a url like:
> site.com/?id=1325
>
> now on the next page I want to select the next record down, regardless of
> its id - so it might be 1287, not neccessarily 1325 -1...
"SELECT id FROM foo WHERE id > $id ORDER BY id LIMIT 1;" will give you
the next highest id. If you want ordering based on the mysql row
ordering then you seriously want to reconsider what you're doing.
>
> I know you can do an offset kind of thing like this:
> ORDER BY id DESC LIMIT 5, 1
>
> But I don't think that would help...
> Am I making sense? Can anyone help?
>
--
David Pashley
david at davidpashley.com
Nihil curo de ista tua stulta superstitione.
More information about the BNMlist
mailing list. Powered by Wessex Networks