meallhour
meallhour

Reputation: 15581

How to select 50 rows everytime from mysql table

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

Answers (1)

Mureinik
Mureinik

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

Related Questions