The LIMIT Clause
tags: #sql/basic_statements
The LIMIT clause can restrict the result set of the query to some maximum number of rows.
The following example sets max with a literal integer to retrieve at most 10 rows from table tab1:
SELECT a, b
FROM tab1
LIMIT 10;
If the LIMIT clause follows the ORDER BY clause, the returned rows are sorted according to the ORDER BY specifications.
Useful in queries to limit to only a subset of the qualifying rows and to identify TOP or BOTTOM k number of records.
The following query returns data about the ten highest-paid employees:
SELECT name, salary
FROM emp
ORDER BY salary DESC LIMIT 10;