我认为ID
from tableschedule
只是一auto_increment
列,正确的加入方式schedule
是.office_hours
office_hours.schedule_id = schedule.semester_id
select *
from schedule
inner join semester
on schedule.semester_id = semester.id
inner join office_hours
on office_hours.schedule_id = schedule.semester_id
更新 1
select *
from schedule
inner join semester
on schedule.semester_id = semester.id
inner join office_hours
on office_hours.schedule_id = schedule.semester_id
INNER JOIN faculty
ON faculty.id = office_hours.faculty_id
INNER JOIN Section
ON Section.faculty_ID = faculty.id AND
Section.Schedule_ID = Schedule.ID
INNER JOIN class
ON Class.ID = Section.Class_ID
INNER JOIN major_class_br
ON major_class_br.class_ID = Class.ID
INNER JOIN major_minor
ON major_class_br.major_minor_id = major_minor.ID
假设每个表上都存在所有列ID
或链接列INNER JOIN
,这就是使用的原因。否则,使用LEFT JOIN
.