0
我們如何加入這些student_info和class_info表沒有公共列,但兩個外鍵都存儲在class_student表中。如何使用沒有公共列的鏈接表連接表
我們如何加入這些student_info和class_info表沒有公共列,但兩個外鍵都存儲在class_student表中。如何使用沒有公共列的鏈接表連接表
調整以適合您的WHERE子句,特定數據庫和JOIN需求。
對於學生的課程:
SELECT *
FROM student_info JOIN class_student ON student_info.student_id = class_student.student_id
JOIN class_info ON class_student.class_id = class_info.class_id
WHERE student_info.student_id = ...
對於一類的學生:
SELECT *
FROM class_info JOIN class_student ON class_info.class_id = class_student.class_id
JOIN student_info ON class_student.student_id = student_info.student_id
WHERE class_info.class_id = ...