SQL error
LIMIT #,# syntax is not supported (PostgreSQL)
Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)
Short answer
LIMIT offset, count is MySQL syntax that SQLite also accepts. PostgreSQL wants the standard form: LIMIT 3 OFFSET 2 (three rows, after skipping two). That form works in SQLite too.
The exact messages
- PostgreSQLERROR: LIMIT #,# syntax is not supported
- SQLiteNo error, but a silent surprise: see below.
How to read this message
This is what PostgreSQL 18.6 prints for the broken query below, the way psql shows it. LINE gives the line it was reading when it gave up, and the ^ marks the exact spot. HINT is PostgreSQL's own suggestion, and it's usually worth following.
ERROR: LIMIT #,# syntax is not supported
LINE 4: LIMIT 2, 3;
^
HINT: Use separate LIMIT and OFFSET clauses.Why it happens
A query written for MySQL or SQLite
Paging code often uses LIMIT offset, count. Swap it for LIMIT count OFFSET offset.
The numbers read backwards
In LIMIT 2, 3 the 2 is the offset. In LIMIT 3 OFFSET 2 the order is explicit, which avoids a quiet off-by-one.
Reproduce it, then fix it
Both queries run on a real database in your browser. Switch dialects to compare.
SELECT name
FROM pets
ORDER BY name
LIMIT 2, 3;SELECT name
FROM pets
ORDER BY name
LIMIT 3 OFFSET 2;Skip two rows, return three. Same rows as SQLite's LIMIT 2, 3, in a form every database accepts.
The fix returns, PostgreSQL: 3 rows
| name |
|---|
| Bruno |
| Clover |
| Gizmo |
The fix returns, SQLite: 3 rows
| name |
|---|
| Bruno |
| Clover |
| Gizmo |
Experiment with it: PostgreSQL playground·SQLite playground
What SQLite does instead
SQLite accepts the MySQL-style LIMIT 2, 3, where the first number is the offset and the second the count. Easy to misread, and not portable.
Official documentation
Stop hitting this error
Practise the concept behind it in a five-minute lesson, or read the full guide: SQL ORDER BY, LIMIT and OFFSET.