Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

sql - Column Ambiguously Defined

I'm getting:

ORA-00918: column ambiguously defined 00918. 00000 - "column ambiguously defined"

Whenever I try to run:

select 
first_name as student_first_name, 
last_name as student_last_name

from super_student ss

inner join sub_distance_learning sdl
on sdl.student_id = ss.id

inner join sub_academic_tutor sat
on sat.id = sdl.academic_tutor_id

inner join super_sub_lecturer ssl
on ssl.id = sat.lecturer_id

inner join super_employee se
on se.id = ssl.employee_id;

The error only shows when this is included:

inner join super_employee se
on se.id = ssl.employee_id;

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Obviously, more than one table has first_name and/or last_name in it, presumably super_student and super_employee.

Use the table aliases that you nicely defined:

select ss.first_name as student_first_name, 
       ss.last_name as student_last_name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...