下载此文档

实验4:数据库的嵌套查询.doc


文档分类:IT计算机 | 页数:约4页 举报非法文档有奖
1/4
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/4 下载此文档
文档列表 文档介绍
学号: 姓名:实验四:数据库的嵌套查询实验实验目的:加深对嵌套查询语句的理解。实验内容:使用IN、比较符、ANY或ALL和EXISTS操作符进行嵌套查询操作。实验步骤:’刘晨’在同一个系学习的学生的信息:select*fromstudentwheresdeptin(selectsdeptfromstudentwheresname='刘晨')比较:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='刘晨')的异同比较:select*fromstudentwheresdept=(selectsdeptfromstudentwheresname='刘晨')andsname<>'刘晨’比较:selectS1.*fromstudentS1,=='刘晨'结果:查询选修了课程名为’信息系统’的学生的学号和姓名:答:selectsno,snamefromstudentwheresnoin (selectsnofromsc oin (ofromcourse ame='信息系统' ) )查询选修了课程’1’和课程’2’的学生的学号(姓名):selectsnofromstudentwheresnoin(o='1')andsnoin(o='2'),=='1'o='2'o='1'andsnoin(o='2')比较:查询选修了课程’1’或课程’2’的学生的sno:o='1'o='2'比较连接查询:,=='1'o='2'结果:第一类的查询结果为’95001’和’95004’;第二类查询结果有7种(包含重复);最后一类利用自连接查询结果有两种。’刘晨’年龄小的所有学生的信息:答:select*fromstudentwheresage< (selectsagefromstudent wheresname='刘晨'),All谓词的子查询(对于ALL全称量词,建议改成否定之否定存在量词)查询其他系中比信息系(IS)某一学生年龄小的学生姓名和年龄;答:selectsname,sagefromstudentwheresdept<>'IS'andsage<any (selectsagefromstudent wheresdept='IS' )查询其他系中比信息系(IS)学生年龄都小的学生姓名和年龄:答:selectsname,sagefromstudentwheresdept<>'IS'andsage<all (selectsagefromstudent wheresdept='IS' )查询与计算机系(CS)系所有学生的年龄均不同的学生学号,姓名和年龄:答:selectsno,sname,sagefromstudentwheresage<>all (selectsagefromstudent wheresdept='IS' ),姓名和年龄:s

实验4:数据库的嵌套查询 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数4
  • 收藏数0 收藏
  • 顶次数0
  • 上传人x11gw27s
  • 文件大小32 KB
  • 时间2019-10-29