How to select every second record

2005-01-27 Thread Martin Rytz
Hi SQL-Users 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? Thank you! Greetings, Martin

Re: How to select every second record

2005-01-27 Thread Martijn Tonies
Hello, 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? Besides the obvious why? ... A table, by itself, does not have every second record, as it has

RE: How to select every second record

2005-01-27 Thread Jay Blanchard
[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

RE: How to select every second record

2005-01-27 Thread Jay Blanchard
[snip] Jay Blanchard wrote: [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

RE: How to select every second record

2005-01-27 Thread Gordon
(0.00 sec) -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Thursday, January 27, 2005 8:50 AM To: Alessandro Sappia; mysql@lists.mysql.com Subject: RE: How to select every second record [snip] Jay Blanchard wrote: [snip] Is it possible to select only every second

RE: How to select every second record

2005-01-27 Thread Jay Blanchard
[snip] mysql set @a:=0; Query OK, 0 rows affected (0.00 sec) mysql select @a:[EMAIL PROTECTED],mod(@a,2),ordr_ID, poft_Sub_Month from er_poft group by 3,4 having mod(@a,2) = 0 limit 5; +--+---+-++ | @a:[EMAIL PROTECTED] | mod(@a,2) | ordr_ID |