Skip
Arish's avatar

96. LIMIT Clause


LIMIT Clause

LIMIT restricts the number of rows returned.

Syntax

sql
1SELECT * FROM students LIMIT n;

Example: First 5 Students

sql
1SELECT * FROM students LIMIT 5;

Returns only 5 rows.

With ORDER BY

sql
1SELECT * FROM students
2ORDER BY marks DESC
3LIMIT 5;

Top 5 by marks.