ORA-00918: column ambiguously defined

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

 

 1,743 views last month,  1 views today

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Leave a Reply

Do NOT follow this link or you will be banned from the site!