List:General Discussion« Previous MessageNext Message »
From:Jay Blanchard Date:January 27 2005 2:30pm
Subject:RE: How to select every second record
View as plain text  
[snip]
Is it possible to select only every second record from a record set?
 
I should select the record-number 1, 3, 5, 7, 9, ... or record-number 2,
4,
6, 8, ...
 
Can this be done with LIMIT?
[/snip]

Not LIMIT, but you can use MOD, especially with an auto-increment field
(id in this case is the auto-increment field)

select * from table where mod(id, 2) <> '0' returns odd rows
select * from table where mod(id, 2) <> '1' returns even rows
Thread
How to select every second recordMartin Rytz27 Jan
  • Re: How to select every second recordMartijn Tonies27 Jan
RE: How to select every second recordJay Blanchard27 Jan
RE: How to select every second recordJay Blanchard27 Jan
  • RE: How to select every second recordGordon27 Jan
RE: How to select every second recordJay Blanchard27 Jan