In mysql, you can easily paginate query results by using a feature of the select statement. The syntax of the select statement:
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL ]
select_expression,...
[INTO OUTFILE 'file_name' export_options]
[FROM table_references
][WHERE where_definition]
[GROUP BY col_name,...]
[ HAVING where_definition]
[ORDER BY {unsigned_integer | col_name | formula} ][ASC | DESC] ,...]
[LIMIT ][offset,] rows]
[PROCEDURE procedure_name] ]
The LIMIT clause can be used to limit the amount of data returned by the SELECT statement. It has one or two parameters. If two parameters are given, the first parameter specifies the position of the first row returned in all data. , starting from 0 (note not 1), the second parameter specifies the maximum number of returned rows
. For example:
select * from table LIMIT 5,10; #Return the 6-15 rows of data
select * from table LIMIT 5; #Return the first 5 rows
select * from table LIMIT 0,5; # Return the first 5 rows