SQLSTATE 42702Severity lowLab verified

Incident brief

Column reference is ambiguous

A query referenced a bare column name that exists in more than one table in the FROM clause, so PostgreSQL could not tell which table you meant.

What lands in your log

ERROR: column reference "id" is ambiguous

Reproduced on PostgreSQL 16.14Verified 2026-07-19 (isolated lab, PostgreSQL 16.14)Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What triggers it
Create two tables that share a column name (here both have id and name).
Fix
Qualify the column with its table name or alias (employees.id, or e.id).
Proof
Reproduced on PostgreSQL 16.14 → Selecting the bare column id from a USING (name) join of two tables that both have an id column was rejected with SQLSTATE 42702. Qualifying the column resolved it.

Fix

What to do right now

Application-level steps for this error.

  • Qualify the column with its table name or alias (employees.id, or e.id).
  • If the column is a shared join key, list it in USING (...) so the join merges it into a single output column.
  • Give tables short aliases and always qualify shared column names in multi-table queries.
Fix SQL
-- qualify the column so PostgreSQL knows which table's id you mean
SELECT e.id, e.name
FROM employees e
JOIN departments d ON e.id = d.id;

Connected

Everything this error touches

Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.

Open in the interactive map →

Verification

PG 16.14
Last verified
2026-07-19 (isolated lab, PostgreSQL 16.14)
Verification scope
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed
ShareLinkedInX

Went further?

Pro unlocks the second lab proof

Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.

FollowSubstackLinkedInnew errors · lab notes · hiring loops