LIMIT clause
The LIMIT clause is used to limit the number of records returned by a query. It is particularly useful when you want to retrieve a specific number of records from a table.
When using the LIMIT clause, it is possible to paginate results by using the START clause to start from a specific record from the result set. It is important to note that the START count starts from 0.
Syntax
Clause Syntax
LIMIT @number [START @start 0]
Examples
SELECT * FROM person LIMIT 10;
SELECT * FROM person LIMIT 10 START 50;
SELECT * FROM [1,2,3,4,5,6,7,8,9,10] LIMIT 5 START 4;
Result
The LIMIT clause followed by 1 is often used along with the ONLY clause to satisfy the requirement that only up to a single record can be returned.
SELECT * FROM ONLY person:jamie;
SELECT * FROM ONLY person WHERE name = "Jaime";
SELECT * FROM ONLY person WHERE name = "Jaime" LIMIT 1;