SQLite LIMIT proviso is utilized to restrict the information sum returned by the SELECT assertion.
Syntax
Following is the essential punctuation of SELECT proclamation with LIMIT condition.
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows]
Following is the linguistic structure of LIMIT proviso when it is utilized alongside OFFSET statement.
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows] OFFSET [row num]
SQLite motor will restore columns beginning from the following line to the given OFFSET as demonstrated underneath in the last model.
Example
Consider COMPANY table with the accompanying records −
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
Following is a model, which restricts the column in the table as per the quantity of lines you need to get from table.
sqlite> SELECT * FROM COMPANY LIMIT 6;
This will create the accompanying outcome.
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
Anyway in specific circumstances, you may have to get a bunch of records from a specific counterbalance. Here is a model, what gets 3 records beginning from the third position.
sqlite> SELECT * FROM COMPANY LIMIT 3 OFFSET 2;
This will deliver the accompanying outcome.
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
3 Teddy 23 Norway 20000.0
4 Mark 25 Rich-Mond 65000.0
5 David 27 Texas 85000.0