seems like it would be easier to write a perl script #repeated SQL selects $count=0; $sth = $dbh->prepare(qq(select * from table LIMIT ?,?)); while ($sth){ $sth->execute($count,1); $ref =$sth->fetchrow_arrayref(); print FILEHANDLE "my item is $ref->[0],$ref->[1]...etc\n"; $count+=5; }
#or use modulo $count=0; $sth = $dbh->prepare(qq(select * from table)); $sth->execute(); $ref =$sth->fetchrow_arrayref(); @stuff = @$ref; #dereference the array $total = @stuff; #get item count LINE: while ($total) { next LINE unless ($count == 0||$count % 5 == 0){ print FILEHANDLE "my item is $ref->[0],$ref->[1]...etc\n"; } continue { $count++; $total--;} Jim -----Original Message----- From: SpamSucks86 [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 21, 2002 8:38 PM To: [EMAIL PROTECTED] Subject: Return every Nth row in a result set What would be the SQL query to return every Nth row in a result set? So it would return the 5th row, the 10th row, the 15th row, etc. Thanks for any and all replies! --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php