Zest.

SQL: Pagination

A short, tested SQL example for pagination. Copy it and adjust the names and paths for your project.

SQL
SELECT * FROM posts ORDER BY id LIMIT 20 OFFSET 40;      -- page 3

-- faster for deep pages: keyset pagination
SELECT * FROM posts WHERE id > 1234 ORDER BY id LIMIT 20;

Find it in Zest

Search for “sql pagination” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More SQL examples

All SQL examples