Page 1 of 1

consecutive rows

Posted: Sun Mar 26, 2006 4:10 pm
by alix
i have many of rows in a table.. all of them have a number identifyer thats auto incremented. Im trying to make a script that each time the script is called it selects one row then pulls the info from it.. then the next time its called, it pulls the next row and moves on down the list in order. So it'll rotate through each of the rows in the table. The problem is that the id number isnt consecutive because some rows have been removed. I created a table that the script will store the last row accessed and then the next time its called it can move on. Whats the best way to add 1 to the last row called.. check to see if it exsists, if not add 1 more to that number check to see if its there.. if so call the information and move on with the rest of the script?

Posted: Sun Mar 26, 2006 4:12 pm
by feyd
use the limit clause (MySQL)

Posted: Sun Mar 26, 2006 4:18 pm
by s.dot
in addition to feyd's post

you won't be adding 1 to the last row called
you'll be selecting the next record where id > that record

using limit 1, like suggested above

Posted: Sun Mar 26, 2006 4:21 pm
by feyd
I was actually suggesting a slightly different route: LIMIT 1, {row_number}, which would allow for the order in which the records come to be chosen and dictated by the rest of the query.