SQLite Limit

Summary: in this tutorial, you will learn how to use SQLite LIMIT clause to constrain the number of rows returned by a query.

Introduction to SQLite LIMIT clause

The LIMIT clause is an optional part of the  SELECT statement. You use the LIMIT clause to constrain the number of rows returned by the query.

For example, a SELECT statement may return one million rows. However, if you just need the first 10 rows in the result set, you can add the LIMIT clause to the SELECT statement to retrieve 10 rows.

The following illustrates the syntax of the LIMIT clause.

SELECT
	column_list
FROM
	table
LIMIT row_count;Code language: SQL (Structured Query Language) (sql)

The row_count is a positive integer that specifies the number of rows returned.

For example, to get the first 10 rows in the tracks table, you use the following statement:

SELECT
	trackId,
	name
FROM
	tracks
LIMIT 10;Code language: SQL (Structured Query Language) (sql)

Try It