Re: Return every Nth row in a result set

2002-12-22 Thread Richard Clarke
. > I can't do it by ID because what if a row in the middle somewhere gets > deleted? I need to do it by the position in the table, and a static > numbering column won't work. This is a solution someone on EFNet came up > with: > > SET @rowcount=0; > select docid,@rowcount:=@rowcount+1 as num

Re: Return every Nth row in a result set

2002-12-22 Thread ric
. > I can't do it by ID because what if a row in the middle somewhere gets > deleted? I need to do it by the position in the table, and a static > numbering column won't work. This is a solution someone on EFNet came up > with: > > SET @rowcount=0; > select docid,@rowcount:=@rowcount+1 as num

RE: Return every Nth row in a result set

2002-12-22 Thread SpamSucks86
rows in set (0.00 sec) -Original Message- From: Benjamin Pflugmann [mailto:[EMAIL PROTECTED]] Sent: Sunday, December 22, 2002 10:41 AM To: SpamSucks86 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Return every Nth row in a result set Hello. On Sun 2002-12-22 at 08:56:43 -0500,

Re: Return every Nth row in a result set

2002-12-22 Thread Benjamin Pflugmann
Hello. On Sun 2002-12-22 at 08:56:43 -0500, [EMAIL PROTECTED] wrote: > I really don't want to do this client side (I'd have to execute > approximately 10 queries for every page load just for this small task). > Selecting the entire table into a temp table to number the rows also > seems rather ine

RE: Return every Nth row in a result set

2002-12-22 Thread SpamSucks86
I really don't want to do this client side (I'd have to execute approximately 10 queries for every page load just for this small task). Selecting the entire table into a temp table to number the rows also seems rather inefficient. I was reading in a book at Barnes and Noble yesterday which said to

Re: Return every Nth row in a result set

2002-12-21 Thread ric
Dear Spamsucks86, With Mysql 4.0.x I think you are limited to either performing the algorithm at the client side as James suggested or using temporary tables and mysql variables at the server side. create table test (var int); insert into test values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(1

RE: Return every Nth row in a result set

2002-12-21 Thread JamesD
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