MySQL Forums
Forum List  »  Newbie

Re: unique ID field, getting next and previous existing ID from table
Posted by: Bob Field
Date: February 10, 2007 12:25PM

Previous ID:
SELECT id FROM $mytable WHERE id < $id ORDER BY ID DESC LIMIT 1;
Next ID:
SELECT id FROM $mytable WHERE id > $id ORDER BY ID ASC LIMIT 1;

Options: ReplyQuote


Subject
Written By
Posted
Re: unique ID field, getting next and previous existing ID from table
February 10, 2007 12:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.