Skip to content

Instantly share code, notes, and snippets.

@michiel
Forked from ssokolow/pagination_example.sql
Created April 8, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michiel/d91076c1bbfe15296720302a3e19ed61 to your computer and use it in GitHub Desktop.
Save michiel/d91076c1bbfe15296720302a3e19ed61 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