SQL error
syntax error at end of input / incomplete input
Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)
Short answer
The query stops before it's finished: a parenthesis is never closed, a CASE has no END, or a clause ends in mid-air (WHERE, AND). Read the end of the query and finish what it opened.
The exact messages
- PostgreSQLERROR: syntax error at end of input
- SQLiteincomplete input
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.
ERROR: syntax error at end of input
LINE 3: WHERE city IN ('Austin', 'Denver'
^SQLite 3.54.1 reports the same mistake as incomplete input, with no line number: look for the word or column it names.
Why it happens
An unclosed parenthesis
IN ('Austin', 'Denver' or COUNT(* with no ). Count opening and closing brackets; editors highlight the matching pair.
CASE without END
Every CASE needs an END, even when there's only one WHEN.
A clause cut off
A query that ends at WHERE, AND or ORDER BY, often after deleting the last condition.
Reproduce it, then fix it
Both queries run on a real database in your browser. Switch dialects to compare.
SELECT name, city
FROM customers
WHERE city IN ('Austin', 'Denver'SELECT name, city
FROM customers
WHERE city IN ('Austin', 'Denver');Close the parenthesis. A trailing semicolon isn't required, but it makes a cut-off query easier to spot.
The fix returns, PostgreSQL: 6 rows
| name | city |
|---|---|
| Maya Ortiz | Austin |
| Jonah Reed | Denver |
| Priya Nair | Austin |
| Ellie Park | Denver |
| Lena Fischer | Austin |
| Diego Santos | Denver |
The fix returns, SQLite: 6 rows
| name | city |
|---|---|
| Maya Ortiz | Austin |
| Jonah Reed | Denver |
| Priya Nair | Austin |
| Ellie Park | Denver |
| Lena Fischer | Austin |
| Diego Santos | Denver |
Experiment with it: PostgreSQL playground·SQLite playground
Other forms of this mistake
Each one was run when this page was built; the result is what the engine really does.
SELECT name FROM customers WHEREPostgreSQLERROR: syntax error at end of input
A WHERE with no condition.
SELECT name, CASE WHEN price > 12 THEN 'pricey' FROM menu_itemsSQLitenear "FROM": syntax error
A CASE without END doesn't always reach the end: here SQLite stops at FROM, where it expected END.
Official documentation
Stop hitting this error
Practise the concept behind it in a five-minute lesson, or read the full guide: The SQL SELECT statement.