List:General Discussion« Previous MessageNext Message »
From:Jay Pipes Date:August 5 2006 2:31am
Subject:Re: previous and next query
View as plain text  
On Fri, 2006-08-04 at 17:14 -0700, Tanner Postert wrote:
> 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?

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

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