JamesT
JamesT

Reputation: 13

Oracle apex ORA-00918: column ambiguously defined

Hi guys I have a query like somethign below. I am using two inner join and I am select from two two but different coloums

the first inner join changes to see if any of the staffs shares a company vehicle with other staff.

The second inner join changes to see if the what staff level drivers what type of vechicle in the company.

select 
van_col1, van_col2, admin_col3, admin_col4
from 
user
INNER JOIN
admin
ON 
user.van_col1=adim.admin_col3
INNER JOIN
user
ON
adim
adim.admin_col3=user.van_col2

Upvotes: 0

Views: 1138

Answers (1)

juergen d
juergen d

Reputation: 204766

If you join the same table twice then you have to use alias names to differ the joins of the table

select u1.van_col1, u2.van_col2, a.admin_col3, a.admin_col4 
from user u1
INNER JOIN admin a ON u1.van_col1 = a.admin_col3 
INNER JOIN user u2 ON a.admin_col3 = u2.van_col2

And if you have columns in that tables that are named equaly then you have to tell the DB from which table you like to take the column, otherwise it would be ambiguous.

Upvotes: 1

Related Questions