LIMIT in SQL
In SQL, the LIMIT
clause is used to restrict the number of rows returned by a query. It's particularly useful when you want to retrieve a specific number of rows or paginate results.
Syntax
SELECT column1, column2, ...
FROM table_name
LIMIT number_of_rows;
Example
SELECT * FROM products
LIMIT 10;
This query retrieves the first 10 rows from the products
table.
The LIMIT
clause in SQL allows you to control the size of result sets, improving query performance and readability, especially when dealing with large datasets.