MySQL查询中LIMIT关键字有什么用?
示例
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)登录后复制
但是,如果我们只想在输出中获取前 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)登录后复制