Reputation: 5251
I am using a query which is returning around 5000 rows in all.
I want to give facility to user to jump to any particular record by entering the record number.
so for example if the user enters 10 I want to jump to record #10 and retrieve its values.
Using mysql_fetch_assoc is a painful and very slow.
How can I do this easily and quickly?
TIA
Yogi Yang
Upvotes: 0
Views: 352
Reputation: 521053
There is no concept of record "#10" in MySQL, or really in most databases, as records have no internal ordering, and are modeled as sets. That being said, if you want to return a result a record offset by a certain amount, you could use LIMIT
with OFFSET
:
SELECT col
FROM yourTable
ORDER BY someCol -- use this to order if you want
LIMIT 1 -- return a single record of interest
OFFSET 9 -- start at record #10
Upvotes: 3