ORA-00918 Error Message
Learn the cause and how to resolve the ORA-00918 error message in Oracle.
Description
When you encounter an ORA-00918 error, the following error message will appear:
- ORA-00918: column ambiguously defined
Cause
You tried to execute a SQL statement that joined two or more tables, where a column with the same name exists in both tables.
Resolution
The option(s) to resolve this Oracle error are:
Option #1
Prefix the column with the table name and then re-execute the statement.
For example, if you tried to execute the following SQL statement:
SELECT supplier_id, quantity FROM suppliers INNER JOIN orders ON suppliers.supplier_id = orders.supplier_id;
You would receive the following error message:
Since the supplier_id column exists in both the suppliers and orders table, you need to prefix the column with the table name as follows:
SELECT suppliers.supplier_id, quantity FROM suppliers INNER JOIN orders ON suppliers.supplier_id = orders.supplier_id;
No comments:
Post a Comment