SQLite table walk

I would like to implement or use functionality to traverse through a table in SQLite.

If I have a table Products

that has 100k rows, I would like to get maybe 10k rows at a time. Something similar to how a web page would list data and have a link < Previous .. Next >

to traverse the data.

Are there selection commands that can make this simple? I see and try to use ROWID in conjunction with LIMIT, which looks ok if no data is ordered.

// This seems to work if not ordered.

SELECT * FROM Products WHERE ROWID BETWEEN x AND y;

      

+2


a source to share


1 answer


Are you looking for offset and constraint ? SQLite supports them. Then you can use order by which is also supported by SQLite.

EDIT: To develop, 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.



+3


a source







All Articles