版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
实验三:数据库的嵌套查询实验实验目的:加深对嵌套查询语句的理解。实验内容:使用IN、比拟符、ANY或ALL和EXISTS操作符进行嵌套查询操作。实验步骤:一.使用带IN谓词的子查询1.查询与’刘晨’在同一个系学习的学生的信息:比拟select*fromstudentwheresdeptin(selectsdeptfromstudentwheresname='刘晨')与:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='刘晨')的异同比拟:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='刘晨')andsname<>‘刘晨’与:selectS1.*fromstudentS1,studentS2whereS1.sdept=S2.sdeptandS2.sname='刘晨'的异同2.查询选修了课程名为’信息系统’的学生的学号和姓名:比拟selectsno,snamefromstudentwheresnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecname='信息系统'))与:selectsno,snamefromstudentwheresnoin(selectsnofromsc,coursewheresco=courseoandcname='信息系统')3.查询选修了课程’1’和课程’2’的学生的学号:selectsnofromstudentwheresnoin(selectsnofromscwherecno='1')andsnoin(selectsnofromscwherecno='2')比拟:查询选修了课程’1’或课程’2’的学生的sno:selectsnofromscwherecno='1'orcno='2'比拟连接查询:selectA.snofromscA,scBwhereA.sno=B.snoandAo='1'andBo='2'二.使用带比拟运算的子查询
4.查询比’刘晨’年龄小的所有学生的信息:select*fromstudentwheresage<(selectsagefromstudentwheresname='刘晨')三.使用带Any,All谓词的子查询5.查询其他系中比信息系(IS)某一学生年龄小的学生姓名和年龄;selectsname,sagefromstudentwheresage<Any(selectsagefromstudentwheresdept='IS')andsdept<>'IS'6.查询其他系中比信息系(IS)学生年龄都小的学生姓名和年龄:selectsname,sagefromstudentwheresage<ALL(selectsagefromstudentwheresdept='IS')andsdept<>'IS'7.查询与计算机系(CS)系所有学生的年龄均不同的学生学号,姓名和年龄:selectsno,sname,sagefromstudentwheresage<>all(selectsagefromstudentwheresdept='CS')四.使用带Exists谓词的子查询和相关子查询8.查询与其他所有学生年龄均不同的学生学号,姓名和年龄:selectsno,sname,sagefromstudentAwherenotexists
(select*fromstudentBwhereA.sage=B.sageandA.sno<>B.sno)9.查询所有选修了1号课程的学生姓名:selectsnamefromstudentwhereexists(select*fromscwheresno=student.snoandcno='1')10.查询没有选修了1号课程的学生姓名:selectsnamefromstudentwherenotexists(select*fromscwheresno=student.snoandcno='1')11.查询选修了全部课程的学生姓名:SQLServer中:selectsnamefromstudentwherenotexists(select*fromcoursewherenotexists(select*fromscwheresno=student.snoandcno=courseo))11.查询至少选修了学生95002选修的全部课程的学生的学号:SQLServer中:selectdistinctsnofromscAwherenotexists(select*fromscBwheresno='95002'andnotexists(select*fromscCwheresno=A.snoandcno=Bo))12.求没有人选修的课程号cno和cnamecname:selectcno,cnamefromcourseCwherenotexists(select*fromscwheresco=Co)13*.查询满足条件的(sno,cno)对,其中该学号的学生没有选修该课程号cno的课程SQLServer中:selectsno,cnofromstudent,coursewherenotexists(select*fromscwherecno=courseoandsno=student.sno)14*.查询每个学生的课程成绩最高的成绩信息(sno,cno,grade):select*fromscAwheregrade=(select
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- T/SICCA 013-2022空气除菌膜的除菌率试验方法
- T/SHSOT 013-2023化妆品原料皮肤致敏整合评估和测试策略的3选2方法
- T/COEMA 102S-2021异步无灰度LED 显示屏控制器(卡)通用技术要求
- T/CI 297-2024水利水闸加固工程检测及质量评定规范
- 2026年核反应堆系统设计工程师资格认证考试试题及答案
- T/TMAC 124-2025阀门行业数字化转型实施指南
- T/YSIA 009-2024“宜春宜品”农产品品牌认定和管理 通用要求
- 2026下半年事业编医疗卫生岗招聘考试必刷题题库及解析
- T/UNP 343-2024老年人健康功能用品
- 2026年防汛抗旱业务知识模拟试题及答案
- fde+行业研究报告-霞光智库-202609
- 液化气站安全试题及答案
- 江苏省常州市2026年中考数学试卷(含答案)
- 各快递公司应急预案(3篇)
- 2026年国庆节祖国发展成就课件
- 2026-2030中国应急救援装备行业发展分析及发展趋势研究报告
- 2026江苏省高一英语月考综合卷(阶段检测)
- 2025云南红河投资有限公司第二批次招聘3人笔试历年常考点试题专练附带答案详解2套试卷
- (2026年)气管插管术的配合与护理课件
- 2026年中原农业保险股份有限公司招聘67人备考题库附答案详解
- 《钢结构设计原理》课件 第5章 受弯构件
评论
0/150
提交评论