语法格式:
select 查询列表
from 表名
...(其他内容)
limit offset,size;
offset 要显示条目的起始索引(索引从0开始),size表示要显示的个数。limit放在查询语句的最后。
示例:
mysql> select * from dbname.student;
+------+-------+------+
| id | name | age |
+------+-------+------+
| 1 | xuxin | 18 |
| 3 | h | 18 |
| 4 | w | 20 |
| 5 | 222 | 18 |
| 6 | xx | 18 |
+------+-------+------+
5 rows in set (0.00 sec)mysql>
mysql>
mysql> select * from dbname.student limit 0,2;
+------+-------+------+
| id | name | age |
+------+-------+------+
| 1 | xuxin | 18 |
| 3 | h | 18 |
+------+-------+------+
2 rows in set (0.00 sec)mysql> select * from dbname.student limit 2,2;
+------+------+------+
| id | name | age |
+------+------+------+
| 4 | w | 20 |
| 5 | 222 | 18 |
+------+------+------+
2 rows in set (0.00 sec)mysql> select * from dbname.student limit 4,2;
+------+------+------+
| id | name | age |
+------+------+------+
| 6 | xx | 18 |
+------+------+------+
1 row in set (0.00 sec)mysql>