SQL LIMIT Clause
Syntax
The LIMIT clause in SQL is used to specify the maximum number of rows to return in the result set.
-- Retrieve a specific number of rowsSELECT column1, column2FROM table_nameLIMIT number_of_rows;
-- Retrieve rows with an offsetSELECT column1, column2FROM table_nameLIMIT offset, number_of_rows;Example
-- Retrieve the first 2 rowsSELECT name, departmentFROM employeesLIMIT 2;/* Output:| name | department ||------------|------------|| John Doe | Sales || Jane Smith | Marketing |*/
-- Retrieve 2 rows starting from the second rowSELECT name, departmentFROM employeesLIMIT 1, 2;/* Output:| name | department ||-------------|------------|| Jane Smith | Marketing || Alice Brown | HR |*/