示例mysql> select * from student_info;+------+---------+------------+------------+| id | name | address | subject |+------+---------+------------+------------+| 101 | yashpal | amritsar | history || 105 | gaurav | chandigarh | literature || 125 | raman | shimla | computers || 130 | ram | jhansi | computers || 132 | shyam | chandigarh | economics || 133 | mohan | delhi | computers || 150 | saurabh | null | literature |+------+---------+------------+------------+7 rows in set (0.00 sec)
上面的结果集显示表“student_info”总共有 7 行。
但是,如果我们只想在输出中获取前 2 行,那么我们可以使用 limit关键字后跟 2,如下 -
mysql> select * from student_info limit 2;+------+---------+------------+------------+| id | name | address | subject |+------+---------+------------+------------+| 101 | yashpal | amritsar | history || 105 | gaurav | chandigarh | literature |+------+---------+------------+------------+2 rows in set (0.00 sec)
以上就是mysql查询中limit关键字有什么用?的详细内容。
