Reputation: 15581
I want to select 50 rows every time from a table
I have written following query
select * from table order by id asc limit 50 ;
Now, I want to select the next 50 records and then the next 50 records.
What query should I write to fetch the next 50 records?
Upvotes: 1
Views: 2524
Reputation: 311228
You could add an offset
clause to specify where the return value would start. E.g., in the first run:
select * from table order by id asc limit 50 offset 0; -- Returns rows 1-50
And then:
select * from table order by id asc limit 50 offset 50; -- Returns rows 50-100
And so on.
Upvotes: 3