数据库(三)关系数据库标准语言SQL(2)
来源:互联网 发布:王菲暧昧歌词含义知乎 编辑:程序博客网 时间:2024/06/11 00:30
连接查询
查询同时涉及两个以上的表,对应代数运算中的连接。
等值/非等值连接
select Student.*,SC.* from Student,SC where Student.Sno = SC.Sno and SC.Grade>90;自身连接
select first.Cno, second.Cpno from Course first, Course second where first.Cpno = second.Cno;
外连接
select Student.Sno from Student left outer join SC on (Student.Sno = SC.Sno);
嵌套查询
带有in谓词
select Sno from Student where Sdept in (select Sdept from Student where Sname = '张三');带有比较关系运算符
select Sno from SC x where Grade >= (select AVG(Grade) from SC y where y.Sno = x.Sno);带有any(任意值)/all(所有值)
select Sname from Student where Sage < any(select Sage from Student where Sdept = 'CS') and Stept <>'CS';带有exist
只返回查询的逻辑值true/false
select Sname from Student where not exist (select * from SC where Sno = Student.sno and Cno = '1'); 选出没有选1号课程的学生姓名
全称量词的查询
选出至少选择了95001号同学所选全部课程的学生的学号select distinct Sno from SC x where not exists ( select * from SC y where y.Sno = 95001 and not exists(select * from SC z where z.Sno = x.Sno and z.Cno = y.Cno ) );
select Sname from Student where 60 > all(select Score from SC where...);
集合操作
并union 交intersect 差except
select * from Student where Sdept='CS' istersect select * from student where Sage<=19;
选择新数据源
select sno,sname avg_grade from student ,(select sno,avg(grade) as avg_grade from sc group by sno)...
0 0
- 数据库(三)关系数据库标准语言SQL(2)
- 数据库(三)关系数据库标准语言SQL(1)
- 关系数据库标准语言SQL基础2
- 关系数据库标准SQL语言
- 关系数据库标准语言SQL
- 关系数据库标准语言SQL
- 关系数据库标准语言SQL
- 关系数据库标准语言SQL
- 数据库 - 关系数据库标准语言SQL
- 数据库 - 关系数据库标准语言SQL
- 【数据库系统概论】-关系数据库标准语言SQL(2)
- 关系数据库标准语言SQL(一)
- 关系数据库标准语言SQL(二)
- 关系数据库标准语言SQL基础1
- 3-1关系数据库标准语言SQL
- 关系数据库标准语言SQL-1
- 第三章 关系数据库标准语言SQL
- 数据库系统原理复习题(三)——关系数据库标准语言SQL
- Discuz! X3.2学习记录:多数据记录页面增加分页控件
- Mybatis 动态Sql
- JPA 菜鸟教程 1 环境搭建
- 如何处理运营事故
- sql 经常使用的语句(个人)
- 数据库(三)关系数据库标准语言SQL(2)
- 课堂 表单验证 JavaScript js
- Java根据身份证号得到年龄通用方法
- 研究生论坛
- springMVC学习笔记(六) ---- 文件上传
- 使用Maven创建项目
- 手写体识别一探深度神经网络
- easyui中时间格式的转换写法
- leetcode--Pascal's Triangle II