表: student house course 关系:student_course 多对多 student house 多对一 需求:查询房间1 的学生 都学习了什么课程 select s.s_name,c.c_name from student s left outer join student_course sc on (s.sid=sc.sid) left outer join house h on (s.hid=h.hid) left outer join course c on (sc.cid=c.cid) where s.sid in (select sid from student) and h.hid=1; +---------+----------+ | s_name | c_name | +---------+----------+ | freedom | odijfoij | | freedom | in2 | | wer | odijfoij | +---------+----------+
时间: 2024-10-16 10:33:09