当前位置:网站首页>SQL Server 2016 learning records - set query
SQL Server 2016 learning records - set query
2022-07-28 10:38:00 【Hard work Zhang Zhang】
Learning goals :
One 、 Related concepts of set query
Two 、 Several common operations of set query
Learning content :
One 、 Classification of set queries

Two 、 Several common operations of set query
1、 And operate
- form
< Query block >
union
< Query block >
- To participate in union The number of columns of each result of the operation must be the same
- The data type of the corresponding item must be the same
-- Check the elective course 1 Course No. and 2 The student number of course No
select sno from sc where cno=1
union
select sno from sc where cno=2;

2、 Alternating operation and differential operation
standard sql Set intersection and difference operations are not provided in , But it can be achieved indirectly by other methods
-- Check the elective course 1 The students of course No. 1 have gathered and selected 2 The intersection of the student set of course No
select sno from sc
where cno=1 and sno In
(select sno from sc
where cno=2);

-- Query computer science department students with age not older than 19 The difference set of a year old student
select * from student
where sdept='CS' and sage>19;

4、 Sort the results of set operations
- order by Clause can only be used to sort the final query results , Intermediate results cannot be sorted
- In any case ,order by Clause can only appear at the end
- When sorting the results of set operations ,order by The sorting attribute can be specified numerically in the clause
-- Query computer science department students with age not older than 19 The union of year-old students , The results are arranged in ascending order of student number
select * from student
where sdept='CS'
union
select * from student
where sage<=19
order by sno;

边栏推荐
- C语言 输入带空格的字符串
- pt-kill 查询中包含中文字符 导致工具失效的排查
- Install MySQL under centos7, and the online articles are not accurate
- Shortest path topic
- Deadlock algorithm: banker algorithm and security algorithm
- 数据库安全 --- 创建登录名 用户+配置权限【笔记】
- Lucene 查询语法备忘
- 6、MapReduce自定义分区实现
- Machine learning -- handwritten English alphabet 1 -- classification process
- 5、Window端实现Mapreduce程序完成wordcount功能
猜你喜欢

IDEA打包jar包及运行jar包命令

Get to know SuperMap idesktop for the first time

SQL Server 2016 learning records - connection query
![[wechat applet] project practice - lottery application](/img/7b/a0545f077259b3dc971dc246813177.png)
[wechat applet] project practice - lottery application

11. Linked list inversion

SemEval 2022 | 将知识引入NER系统,阿里达摩院获最佳论文奖

ACM winter vacation training 6

7、MapReduce自定义排序实现

8、Yarn系统架构与原理详解

Chapter 1: cross end development of small programs of uniapp ----- create a uniapp project
随机推荐
SDUT 2446 final ranking
Small knowledge in Oracle
Idea packages jar packages and runs jar package commands
8. Numbers that appear more than half of the time in the array
Use of Ogg parameter filter [urgent]
3. Print the linked list in reverse order with the array
6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number
Machine learning -- handwritten English alphabet 1 -- classification process
Database security - create login user + configure permissions [notes]
2020第二届传智杯初赛
ACM寒假集训#4
ogg参数filter的使用问题【急】
SQL Server 2016 learning record - Data Definition
集群为什么需要root权限
Codeforces Round #614 (Div. 2) A. ConneR and the A.R.C. Markland-N
Install mysql5.7 under centos7
读写分离备机备份报错
第一篇:UniAPP的小程序跨端开发-----创建uniapp项目
[application of stack] - infix expression to suffix expression
利用正则表达式从文件路径中匹配文件名