大家好,我是anyux。数据库联表查询很重要,内联查询更是尤为重要。
![7a50bf25883fa1f041652e951eab33c9.png](https://i-blog.csdnimg.cn/blog_migrate/72b793a1f2dc0664de786d70a06fdb86.jpeg)
需要将school.sql文件导入到数据库中
数据库多表联合查询,school库下表的逻辑结构关系都在下图中。可以通过驱动表加子表配合实现所有查询要求。
![ca248e7b608f3cad65ef74cfc393e5e5.png](https://i-blog.csdnimg.cn/blog_migrate/a782a7636461cc8e189445319fddf3a9.jpeg)
统计zhang3,学习了几门课
select STU.sname as 姓名, count(SC.sno) as 数量 from student as STU join sc as SC on STU.sno= SC.sno where STU.sname='zhang3';
查询zhang3,学习的课程名称有哪些?
方法1
select STU.sname as 姓名, COU.cname as 课程名 from student as STU join sc as SC on STU.sno = SC.sno join course as COU on SC.cno = COU.cno where STU.sname='zhang3';
方