Limiting the Display of Results from a SELECT Statement
Limiting the Display of Results from a SELECT Statement
The display of results returned by a query can be limited to a specified number of records by including the LIMIT option with the SELECT statement. When the LIMIT keyword and a numeric parameter are appended to a SELECT statement, at most that number of records will be displayed from the actual result set.
that, like the .MAXROWS system command, the LIMIT option does not affect the query results returned from the server; it serves only to limit what is displayed on the client side. Therefore, using the LIMIT option with CREATE TABLE...SELECT or INSERT...SELECT will not filter the data in any way.
The LIMIT syntax is the following:
<SELECT statement> LIMIT
n
;
where
n
is a positive integer.
For example:
SELECT t1 FROM salestab LIMIT 10;
If the above query returns more than 10 records, only the first 10 records from the result set will be displayed. Otherwise, if the query returns 10 records or less, the LIMIT option is essentially ignored and the full result set is displayed.