MySQL and record numbers

admin

Administrator
Staff member
I've done some pretty extensive searching tonight for an aquaintance who is trying to convert a program to MySQL. What he's trying to do would SEEM pretty insignificant, but the more I search the more certain I am that it's NOT trivial.

He knows he can use the LIMIT to retrieve a certain number of results from a table, and one of the parameters is the beginning record number, the other being the number of records to return.


He executes a query to find an entry, then wants to display that entry and the 9 after it.

What he can't do is find the record number of the result of the query. Without that he can't determine where to start the LIMIT at.

I've seen it said that MySQL doesn't use record numbers. Obviously that's not true because the LIMIT is looking for a record number!

If this can't be done, perhaps an alternate method could be described?

(hopefully better than my current answer which is:
Search and store the unique identifier of the record returned... select ALL in the table and start looking for that unique identifier one by one, incrementing a counter. When he finds the unique ID, use the counter for the LIMIT.)
 
Back
Top