当前位置:网站首页>SQL Server 2016 学习记录 --- 集合查询
SQL Server 2016 学习记录 --- 集合查询
2022-07-28 10:12:00 【努力的张张】
学习目标:
一、集合查询的相关概念
二、集合查询的几种常用操作
学习内容:
一、集合查询的分类

二、集合查询的几种常用操作
1、并操作
- 形式
<查询块>
union
<查询块>
- 参加union操作的各结果的列数必须相同
- 对应项的数据类型也必须相同
--查询选修了1号课程和2号课程的学生学号
select sno from sc where cno=1
union
select sno from sc where cno=2;

2、交操作与差操作
标准sql中没有提供集合交操作和差操作,但可以用其他方法间接实现
--查询选修了1号课程的学生集合与选修了2号课程的学生集合的交集
select sno from sc
where cno=1 and sno In
(select sno from sc
where cno=2);

--查询计算机科学系的学生与年龄不大于19岁的学生的差集
select * from student
where sdept='CS' and sage>19;

4、对集合操作结果的排序
- order by子句只能用于对最终的查询结果排序,不能对中间结果排序
- 任何情况下,order by 子句只能出现在最后
- 对集合操作结果排序时,order by 子句中可以用数字指定排序属性
--查询计算机科学系的学生与年龄不大于19岁的学生的并集,结果按学号升序排列
select * from student
where sdept='CS'
union
select * from student
where sage<=19
order by sno;

边栏推荐
- 谈谈基于JS实现阻止别人调试通过控制台调试网站的问题
- Vulnerability analysis hevd-0x8.integeroverflow[win7x86]
- PHP生成二维码(学习)
- 基于ModelArts续写最伟大的作品【玩转华为云】
- Deadlock algorithm: banker algorithm and security algorithm
- 中兴通讯总裁徐子阳:5nm芯片将在2021年推出
- centos7下安装mysql,网上文章都不太准
- 【微信小程序】项目实战—抽签应用
- Double pointer technique
- Talk about the problem of preventing others from debugging websites through console based on JS implementation
猜你喜欢

Get to know SuperMap idesktop for the first time

7. Dichotomy -- find a set of repeated or ordered but rotating arrays

PHP generates QR code (learning)

API 网关 APISIX 在Google Cloud T2A 和 T2D 的性能测试

巧用ngx_lua做流量分组

Why should I take the first-class constructor examination? How high is the gold content of the first-class Constructor Certificate?

5、动态规划---斐波那契数列

6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number

多线程与高并发(三)—— 源码解析 AQS 原理

第一篇:UniAPP的小程序跨端开发-----创建uniapp项目
随机推荐
Leetcode076 -- the kth largest number in the array
问题总结档案
Talk about the problem of preventing others from debugging websites through console based on JS implementation
(1)机器学习概念总结
Sword finger offer
B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
️雄关漫道真如铁,而今迈步从头越️
IDEA打包jar包及运行jar包命令
10 minute quick start EVs [play Huawei cloud]
Small knowledge in Oracle
6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number
14、双指针——盛最多水的容器
Problem summary file
死锁算法:银行家算法和安全性算法
10. The penultimate node in the linked list
12、双指针——合并两个有序链表
PL/SQL server语法详解
Record a parent-child project in idea, modify the name of project and module, and test it personally!
2021-10-13arx
MySQL的SQL TRACE一例