mike9182
mike9182

Reputation: 450

Ambiguous Column Name in Select Statement

This query is returning the error "ambiguous column name courses.scheduleNumber". I searched for a solution to the problem, however, a commonly suggested fix was to qualify all of the column names with the table name, which I have already done.

SELECT
  courses.scheduleNumber,
  courses.subject,
  courses.courseNumber,
  courses.sectionNumber,
  courses.credits,
  courses.title,
  courses.room,
  courses.days,
  rooms.building,
  rooms.room,
  courses.startTime,
  courses.endTime,
  courses.instructor
FROM courses
LEFT JOIN courseRooms 
  ON courses.scheduleNumber=courseRooms.scheduleNumber
LEFT JOIN courses 
  ON courseRooms.building=rooms.building AND courseRooms.room=rooms.room;

Upvotes: 0

Views: 515

Answers (3)

Teja
Teja

Reputation: 13544

Two "courses" in your from clause. Replace the "courses" in final left join with "rooms". It should work then.

Upvotes: 0

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181460

You have courses twice in your from clause.

Upvotes: -1

David Ruttka
David Ruttka

Reputation: 14409

I think you mean for that final LEFT JOIN courses to be a LEFT JOIN rooms ?

Upvotes: 8

Related Questions