SQL Pagination Across Databases: LIMIT, TOP, and OFFSET-FETCH Compared
By Sharon Ben-Moshe · August 2, 2026 · 2 min read
Sharon Ben-Moshe is the founder of sqlfmt, a browser-based SQL formatter and validator with misspelled-keyword suggestions across PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery.
PostgreSQL, MySQL, and SQLite page results with LIMIT. SQL Server uses TOP or OFFSET-FETCH. BigQuery uses standard LIMIT/OFFSET. Here's how the syntax — and the gotchas — differ.
Quick answer
PostgreSQL, MySQL, SQLite, and BigQuery all paginate with LIMIT n OFFSET m. SQL Server instead uses either SELECT TOP(n) or, for true offset-based paging, OFFSET m ROWS FETCH NEXT n ROWS ONLY — and that clause requires an ORDER BY, unlike LIMIT elsewhere.
FAQs
Does SQL Server support LIMIT?
No. SQL Server has no LIMIT keyword — use TOP(n) for a simple row cap, or OFFSET ... FETCH NEXT ... ROWS ONLY for offset-based pagination.
Why does my MySQL LIMIT return the wrong rows?
Check the argument order. MySQL uniquely supports LIMIT offset, count as well as LIMIT count — mixing them up silently returns a different page than intended, with no error.
Does OFFSET/FETCH need ORDER BY in SQL Server?
Yes, it's mandatory — SQL Server raises a syntax error if OFFSET ... FETCH NEXT is used without a preceding ORDER BY.
Is pagination deterministic without ORDER BY?
No, in any of these five dialects. Without an ORDER BY on a unique or near-unique column, the database can return rows in a different order between two otherwise-identical paged requests.
Does BigQuery support OFFSET?
Yes — BigQuery uses the same LIMIT n OFFSET m syntax as PostgreSQL, MySQL, and SQLite.
Keep reading
The Comprehensive Guide to SQL Data Types: Storage, Precision, and Cross-Dialect Portability
By Sharon Ben-Moshe · Oct 13, 2026
The complete guide to SQL data types across PostgreSQL, MySQL, SQL Server, and SQLite. Numeric precision, character sets, timestamps, and JSON.
Read postThe Definitive Guide to SQL Window Functions: Syntax, Framing, and Real-World Recipes
By Sharon Ben-Moshe · Oct 13, 2026
The comprehensive guide to SQL window functions. Master OVER, PARTITION BY, ORDER BY, window frames (ROWS vs RANGE), and ranking recipes.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.