Hi,
I got ” ORA-00918: column ambiguously defined ” error in Oracle SQL .
Details of error are as follows.
ORA-00918: column ambiguously defined
The ORA-00918 error is related with the same column name in the join tables. When you use 2 column with the same name exists in the both tables when join two or more tables, you can get this error.
A column name used in a join exists in more than one table and is thus referenced ambiguously. In a join, any column name that occurs in more than one of the tables must be prefixed by its table name when referenced. The column should be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUMN.
To solve this error, you need to use the Table alias or TABLE_NAME.COLUMN_NAME usage especially in the Table Join as follows.
SQL> SELECT employee_id, first_name,last_name,city, department_name FROM hr.employees e JOIN hr.departments d ON d.department_id = e.department_id JOIN hr.locations l ON d.location_id = l.location_id where l.location_id>2400; EMPLOYEE_ID FIRST_NAME LAST_NAME CITY DEPARTMENT_NAME ----------- -------------------- ------------------------- ------------------------------ ------------------------------ 145 John Russell Oxford Sales 146 Karen Partners Oxford Sales 147 Alberto Errazuriz Oxford Sales 148 Gerald
Do you want to learn Oracle SQL, then read the following articles.
Oracle SQL Tutorials For Beginners – Learn Oracle SQL from scratch with Oracle SQL Online Course