mysql,多表的内外连接+子查询
表: 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 | +---------+----------+
posted on 2015-09-15 22:20 freedom's_blog 阅读(316) 评论(0) 编辑 收藏 举报