how to give join twice on same table in plsql
833676Mar 10 2011 — edited Mar 10 2011i am writing a SQL Query in which i have to twice left outer join on the same table one on a primary key and
other on the foreign key i have written the query like this but giving me error
select * FROM OrderMst INNER JOIN
Employee_Mst ON Employee_Mst.EmpID = OrderMst.OrdByDocID INNER JOIN
Visit ON Visit.Visit_ID = OrderMst.OrdVisitID INNER JOIN
Patient ON Patient.PatientId = OrderMst.OrdPatientID LEFT OUTER JOIN
Institute_Master ON OrderMst.RefInstitute = Institute_Master.Institute_Id LEFT OUTER JOIN ---1 join here
Institute_Master ON OrderMst.ReferToInstitute = Institute_Master.Institute_Id-- 2 join here
note : Institute_Id is primary key of table Institute_Master
: ReferToInstitute foreign key OrderMst
this is giving me error
Error report:
SQL Error: ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"