[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
实验五 子查询
一、实验目的
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的语法结构,对嵌套查询有了更深一步的掌握。