Seaquel
PostgreSQL error code

PostgreSQL error 42712

42712 is the SQLSTATE PostgreSQL reports for duplicate alias, in class 42, Syntax Error or Access Rule Violation.

SQLSTATE42712
Condition nameduplicate_alias
Class42 — Syntax Error or Access Rule Violation

Reproduce it, then fix it

Both tables are aliased o, so o.id could mean either one. Give each table its own alias. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

SELECT o.id, o.quantity
FROM orders o
JOIN order_items o ON o.order_id = o.id;
SELECT o.id, oi.quantity
FROM orders o
JOIN order_items oi ON oi.order_id = o.id;

Source: PostgreSQL documentation, Appendix A