SQLite Limit Query - How to Limit Rows Returned in Query Results

Sometimes it is useful to limit the number of rows that are returned from a query. This can be especially useful when querying very large domains.

The SQLite database provides the ability to limit the number of rows returned from a query starting at the beginning of the results using the limit keyword, or returning a section of results from a query using the limit and offset syntax. Listed below are examples of limiting rows with the SQLite database:

Example 1: Returning the first 100 rows from the table named accounts: SELECT * FROM accounts limit 100; Example 2: Returning the first 100 rows from the table named accounts starting at row 10: SELECT * FROM accounts limit 100, offset 10;

Many other databases also support limiting rows returned from queries. Listed below are links that show how to limit rows for other popular databases: