syntax error at or near "`"

Laravel app, just moved from MySQL to PostgreSQL. The full message as Laravel shows it:

SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "`"

Why it happens

Backticks are MySQL-only identifier quotes. Laravel's query builder quotes for you, so these come from raw SQL: DB::statement, whereRaw, selectRaw, old migrations.

Fix

SELECT * FROM users -- no quotes SELECT * FROM "users" -- Postgres identifier quotes

Tested on Postgres 17. Backticks next to a comma or keyword can also show up as: syntax error at or near "," or near "from". Search the codebase for ` in .php files.

More fixes like this one, as tested scripts: Laravel Postgres Error Fix Pack ($19).

Several errors at once? Paste your log into the error matcher. Raw SQL with MySQL syntax: the free SQL translator. Not migrated yet: the free schema risk check finds this kind of problem before the switch. Planning the whole move: Migration Kit ($49, $34.30 with LAUNCH30 until Nov 5).

Other errors after MySQL to Postgres

Published with deed.page