Walking through an SQLite Table
I would like to implement or use functionality that allows stepping through a Table in SQLite.
If I have a Table Products
that has 100k rows, I would like to retrive perhaps 10k rows at a time. Somthing similar to how a webpage would list data and have a < Previous .. Next >
link to walk through the data.
Are there select statement开发者_运维知识库s that can make this simple? I see and have tried using the ROWID in conjunction with LIMIT which seems ok if not ordering the data.
// This seems works if not ordering.
SELECT * FROM Products WHERE ROWID BETWEEN x AND y;
Are you looking for offset and limit? SQLite supports these. You can then use order by, which SQLite also supports.
EDIT: To elaborate, you can do something like:
Select * from Products order by name limit 10000 offset 10000;
This fetches the second 10k page from the table, sorted by name. Watch out for performance issues when dealing with limit/offset and order by.
精彩评论