Skip to content

Instantly share code, notes, and snippets.

@vzool
Forked from ssokolow/pagination_example.sql
Created April 5, 2023 02:44
Show Gist options
  • Save vzool/52e2632dfee4a8527ec37332794c099d to your computer and use it in GitHub Desktop.
Save vzool/52e2632dfee4a8527ec37332794c099d to your computer and use it in GitHub Desktop.
Reasonably efficient pagination without OFFSET (SQLite version)
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment