StudentProfile
-studentid
Registration
-registrationid
-studentid(foreign key to StudentProfile)
RegistrationSchedule
-regscheduleid(is not a primary key,, is not unique,,can have a lot of instances)
-registrationdid(foreign key to registration)
-scheduleid
Schedules
-scheduleid
请注意,时间表中没有regscheduleid 我试过内心加入他们所有但只是结果出现了 我怎样才能得到那个学生的所有日程安排
答案 0 :(得分:0)
这将从学生的个人资料中获取所有信息,以便安排详细信息。
SELECT t.StudentID, s.ScheduleID
FROM StudentProfile t JOIN Registration r
ON t.studentid = r.studentid
JOIN RegistrationSchedule rs
ON r.registrationid = rs.registrationdid
JOIN Schedules s ON rs.scheduleid = s.scheduleid
删除查询中不需要的表格。
如果您要过滤特定学生,请添加WHERE t.studentid = 1234
。