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)
ตารางมี 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)