>From: Waynn Lue [mailto:waynnlue@stripped]
>Sent: Wednesday, November 12, 2008 3:14 AM
>To: MySQL List
>Subject: Row before and after?
>I'm trying to find the first row before and the first row after a
>row. Essentially I want to do these two queries, and get each row.
>SELECT * FROM Users WHERE UserId = <userId> ORDER BY UserId DESC LIMIT
>SELECT * FROM Users WHERE UserId = <userId> ORDER BY UserId LIMIT 1;
>Is there any way to combine this into one query? OFFSET doesn't allow a
>negative number, which is essentially what I want.
[JS] What do you mean by the "row before" and the "row after"? Are you going
by "userId", or by physical row position (essentially undefined)?
SELECT * FROM Users WHERE UserID = <originalID> - 1 OR UserID = <originalID>
do what you want?