Best way to achieve pagination

Hello, I’m using a query to try to achieve pagination. I have something like this:

SELECT * FROM store WHERE _type=“account” AND id > " . $next . " ORDER BY id

Is the above the only way to do it? The trouble is, I would need to put in a specific id from 1-10000 or however many records I have. This isn’t ideal because if I delete a user, I have no way of calculating the next id for the next page. Also, if I want to sort the data by another criteria it’s not going to work.

There may be something I’m missing. Can anyone assist?


You can use Limit and/or offset. For example

SELECT * FROM store WHERE _type=“account” ORDER BY id LIMIT 2 OFFSET 100.

I didn’t know there was OFFSET. Thank you very much!