You can use the LIMIT
clause to specify the maximum number of rows to return in a query. Typically, you
need to specify one or two numbers in the LIMIT
clause. The first number specifies the number of rows to skip from the beginning,
and the second number specifies the maximum number of rows to return.
The following example queries the orders table and limits the number of rows to return to five by using the LIMIT clause.
SELECT orderdate FROM orders LIMIT 5;
-------------
o_orderdate
-------------
1996-04-14
1992-01-15
1995-02-01
1995-11-12
1992-04-26
The following example queries the customer table and returns the information of the third customer to the seventh customer sorted by the creation date.
SELECT * FROM customer ORDER BY create_date LIMIT 2,5