DBAtlas · Database operations atlas

ORA-00918: column ambiguously defined

Oracle

What does it mean?

A column with the same name exists in more than one table in the query, and because it is used without a table/alias prefix, Oracle cannot determine which table it belongs to.

Why does it happen?

Both joined tables have a column with the same name (e.g. ID in both); the column is used unqualified (without a prefix) in SELECT, WHERE or ORDER BY.

How to fix it

Qualify every ambiguous column with the table name or alias: SELECT a.id, b.id FROM tableA a JOIN tableB b ON a.id = b.a_id; Give tables short aliases and prefix all columns to improve readability and clarity.

Open in DBAtlas →

More from this engine