LIMIT restricts the number of rows returned by a query in database systems such as MySQL and PostgreSQL.
Limiting results is useful when exploring large datasets, testing queries, or displaying only a small number of records.
Display the first 10 employees from a table.
SELECT
EmployeeID,
EmployeeName,
Salary
FROM Employees
LIMIT 10;
LIMIT is commonly used for data exploration, previews, pagination, and testing analytical queries.
- LIMIT restricts returned rows.
- It is commonly supported by MySQL and PostgreSQL.
- It is useful for testing queries.
- It can support pagination.
- Other databases may use different syntax.
What does LIMIT do?
LIMIT restricts the number of rows returned by a query.
Is LIMIT supported by every database?
No. Database systems use different syntax, such as TOP in SQL Server or FETCH/OFFSET in standard-style implementations.