MySQL Limit

MySQL Limit

MySQL LIMIT syntax and examples.

MySQL LIMIT syntax

SELECT * FROM table_name
LIMIT val;

SELECT * FROM table_name
WHERE condition
ORDER BY column
LIMIT val;

Table books

ID NAME PRICE
1 book1 20.0
2 book2 25.0
3 book3 15.0
4 book4 12.0
5 book5 18.0

LIMIT example

SELECT * FROM books 
ORDER BY price desc 
LIMIT 1;

Query Result

ID NAME PRICE
2 book2 25.0