MySQL supports the syntax for limit and offset. This article is mainly used for memo
We set up a table for the experiment:
MySQL>createtable limit_offset ( int Primarykey, varchar(+) 0 rows affected (0.01 sec)
Insert data: INSERT into Limit_offset (name) value (val), we insert 20 data
Mysql> Select * fromLimit_offset;+----+--------+|Id|Name|+----+--------+| 1 |Name1|| 2 |Name2|| 3 |Name3|| 4 |Name4|| 5 |Name5|| 6 |Name6|| 7 |Name7|| 8 |Name8|| 9 |Name9|| Ten |Name10|| One |Name11|| A |Name12|| - |Name13|| - |Name14|| the |Name15|| - |Name16|| - |Name17|| - |Name18|| + |Name19|| - |Name20|+----+--------+ -Rowsinch Set(0.00Sec
Usage one: limit m. The syntax is to select the first M bar in the resultset, including M
Mysql> Select * fromLimit_offset limit6;+----+-------+|Id|Name|+----+-------+| 1 |Name1|| 2 |Name2|| 3 |Name3|| 4 |Name4|| 5 |Name5|| 6 |Name6|+----+-------+6Rowsinch Set(0.00Sec
Usage two: Limit m,n. The syntax is to select the N record from the beginning of the ResultSet record, excluding m
Mysql> Select * fromLimit_offset limitTen,6;+----+--------+|Id|Name|+----+--------+| One |Name11|| A |Name12|| - |Name13|| - |Name14|| the |Name15|| - |Name16|+----+--------+6Rowsinch Set(0.00Sec
Usage Three: limit m offset N. Indicates that the M record is selected from the nth record, excluding n (with limit n,m) equivalent
Mysql> Select * fromLimit_offset limit6OffsetTen;+----+--------+|Id|Name|+----+--------+| One |Name11|| A |Name12|| - |Name13|| - |Name14|| the |Name15|| - |Name16|+----+--------+6Rowsinch Set(0.00Sec
MySQL Limit Offset syntax