实验五 子查询
一、实验目的
1.掌握子查询的表示。
2.进一步掌握SQL Server查询分析器的使用方法,加深对SQL语言的嵌套查询语句的理解

二、实验内容
实现查询:
1)求选修了高等数学的学生学号和姓名;
SQL语句:
select snO, sname from student where sno in ( select sno from student course
where cno in(select cno from course where cname='高等数学')) ;
2)求C1 课程的成绩高于张三的学生学号和成绩;
SQL语句:
select sno, score from student course where exists (select sno from s tudent
student course where sname= ' 张三'and cno='C1 ');
3)求其他系中比计算机系某一学生年龄小的学生信息(即求其它系中年龄小计算机系年龄最大者的学生);
SQL语句:
select * from student where sage< (select MAX (sage) from student where spo=
'CS ' ) and spo<>'cs '
4)求其他系中比计算机系学生年龄都小的学生信息;
sql语句:
select * from student where sage< < al1 . (select sage from student where spo=
'Cs ' ) and spo<>'cs '
5)求选修了C2 课程的学生姓名;
sql语句:
select sname from student where exists ( select * from student course where sno
=student.sno and cno=' C2 ' )
6)求没有选修C2课程的学生姓名;
sql语句:
select sname from student where not exists (select * from student course Where
sno=student.snO and cno= 'C2’ )
三、实验总结
本次试验主要要求我们掌握子查询的表示,进-步掌握SQL Server
查询分析器的使用方法,和加深对SQL语言的嵌套查询语句的理解。通过这次实验我又对SQL语句有了更好的理解,巩固了SQL
语法,更加熟悉了SQLServer2005的语法结构,对嵌套查询有了更深一步的掌握。

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信