我们如何加入这些 student_info 和 class_info 表,没有公共列,但两个外键都存储在 class_student 表中。
问问题
52 次
1 回答
0
调整以适合您的 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 = ...
于 2013-10-08T12:32:38.220 回答