sqlite
Database; use; embedded relational database
limit
英[ˈlɪmɪt]美[ˈlɪmɪt]
n.limit;limit;limit,limit
vt.limit,limit
SQLite Limit function syntax
Function:SQLite's LIMIT clause is used to limit the amount of data returned by the SELECT statement.
Syntax: The basic syntax of a SELECT statement with a LIMIT clause is as follows:
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows]
The following is the syntax of the LIMIT clause when used with the OFFSET clause:
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows] OFFSET [row num]
The SQLite engine will return all rows starting from the next row up to the given OFFSET, as shown in the last example below.
SQLite Limit function example
COMPANY 表有以下记录: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0 下面是一个实例,它限制了您想要从表中提取的行数: sqlite> SELECT * FROM COMPANY LIMIT 6; 这将产生以下结果: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 但是,在某些情况下,可能需要从一个特定的偏移开始提取记录。下面是一个实例,从第三位开始提取 3 个记录: sqlite> SELECT * FROM COMPANY LIMIT 3 OFFSET 2; 这将产生以下结果: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0