List:General Discussion« Previous MessageNext Message »
From:Tanner Postert Date:August 5 2006 12:14am
Subject:previous and next query
View as plain text  
so i have a record set:

id user text
1  2  ...
2  6  ...
3  2  ...
4  4  ...
5  2  ...
6  8  ...
7  1  ...
8  8  ...
9  2  ...


so lets say I am looking at record 3. i need to know the previous record in
the table that has that user, as well as the next record in the table that
has that user.

right now i am using 2 queries.

select text from table where user = 2 and id < 3 order by id ASC limit 1;
select text from table where user = 2 and id > 3 order by id ASC limit 1;

is it possible to do this using 1 query?

Thread
previous and next queryTanner Postert5 Aug
  • Re: previous and next queryJay Pipes5 Aug