Limit Clause
- Last Updated: May 15, 2020
- 1 minute read
- DataDirect Connectors
- JDBC
- IBM Db2 5.1
- MySQL 5.1
- Progress OpenEdge 5.1
- SAP Sybase 5.1
- Documentation
Purpose
Places an upper bound on the number of rows returned in the result.
Syntax
LIMIT number_of_rows [OFFSET offset_number]
where:
- number_of_rows
- specifies a maximum number of rows in the result. A negative number indicates no upper bound.
- OFFSET
- specifies how many rows to skip at the beginning of the result set. offset_number is the number of rows to skip.
Notes
- In a compound query, the Limit clause can appear only on the final Select statement. The limit is applied to the entire query, not to the individual Select statement to which it is attached.
Example
This example returns a maximum of 20 rows.
SELECT last_name, first_name FROM emp
WHERE salary > 20000 ORDER BY dept_id LIMIT 20