SQLSTATE 42712Severity lowLab verified

Incident brief

Duplicate table alias

Each table or alias in a FROM clause must have a unique name; using the same alias twice raises this duplicate-alias error.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
Duplicate table alias
What triggers it
Write a FROM clause that references the same table twice with the same alias.
The fix
Give each FROM entry a distinct alias.
Proof
Reproduced on PostgreSQL 18.4 → A single query reproduces SQLSTATE 42712; the repeated alias is rejected before the join runs.

The fix

What to do right now

The immediate, application-level response to this error.

  • Give each FROM entry a distinct alias.
  • When self-joining a table, alias each instance differently (t1, t2).
Fix — SQL
-- Give each FROM entry a distinct alias.
SELECT * FROM ref_demo a, ref_demo b;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed