PostgreSQL: syntax error at or near
ERROR: syntax error at or near "<token>"Postgres could not parse your statement and is pointing at the token where it gave up. Read the LINE and the caret in the error, they mark the exact spot. Common causes are a reserved keyword used unquoted, a missing comma or quote, or syntax borrowed from another database.
What this error means
This is a parser error, raised before the query runs. The at or near part is the key: the quoted token is where parsing failed, though the real mistake is often just before it.
psql and most drivers print a LINE number and a caret (^) under the offending token. That marker is the fastest way to find the problem.
How to fix it
A reserved keyword is used as an identifier
Words like user, order, group, and table are reserved. Double-quote them to use them as names.
-- fails:
SELECT user, order FROM orders;
-- works:
SELECT "user", "order" FROM orders;You used syntax from MySQL or SQL Server
Backticks are not valid in Postgres; use double quotes for identifiers. Check dialect-specific clauses too.
-- MySQL style, fails:
SELECT `name` FROM users;
-- Postgres:
SELECT "name" FROM users;A stray comma, quote, or parenthesis
Look just before the token the error names. A trailing comma before FROM or an unbalanced quote is a frequent cause.
How to avoid it next time
- Read the caret marker first; it saves you scanning the whole query.
- Avoid reserved words as table and column names, or quote them consistently.
Frequently asked questions
The token it names looks fine. Why?
The parser reports where it could no longer make sense of the statement, which is usually right after the real mistake. Check the tokens immediately before the one it names.
Why do backticks not work?
Backticks are MySQL syntax. Postgres uses double quotes for identifiers and single quotes for string literals.
Stop struggling with SQL
Use FluentDB, the AI database client for macOS.
Related errors
Part of the PostgreSQL error reference. Last reviewed 2026-07-31.