Use paging with help of LIMIT clause in Select query in MYSQL
LIMIT is used as paging purpose also, we can limit the number of rows with select statement. When a LIMIT clause contains two numbers, it is used as LIMIT offset, count. So it will skip the offset mentioned rows and return the COUNT rows as output.
Check the use of Limit clause with one parameter.
It will return number of rows as mentioned as one parameter.
SELECT id, name, population
FROM city ORDER BY id
LIMIT 5;
+----+----------------+------------+
| id | name | population |
+----+----------------+------------+
| 1 | Kabul | 1780000 |
| 2 | Qandahar | 237500 |
| 3 | Herat | 186800 |
| 4 | Mazar-e-Sharif | 127800 |
| 5 | Amsterdam | 731200 |
+----+----------------+------------+
Example of LIMIT clause with two numbers:
SELECT id, name, population
FROM city ORDER BY id
LIMIT 3, 5;
+----+----------------+------------+
| id | name | population |
+----+----------------+------------+
| 4 | Mazar-e-Sharif | 127800 |
| 5 | Amsterdam | 731200 |
| 6 | Rotterdam | 593321 |
| 7 | Haag | 440900 |
| 8 | Utrecht | 234323 |
+----+----------------+------------+