当前位置:网站首页>The difference between union and union all in MySQL
The difference between union and union all in MySQL
2022-06-30 23:39:00 【Sun coffee】
One 、 difference 1: Take the intersection of results
1、union: Combine two result sets , Do not include repeating lines , amount to distinct, At the same time, sort the default rules ;
2、union all: Combine two result sets , Include repeating lines , That is, all the results are displayed , Whether it's repetition or not ;
Two 、 difference 2: The operation after getting the result
1、union: Will sort the obtained results
2、union all: No sort operation will be performed on the obtained results
3、 ... and 、 difference 3:
1、union See the results ID=3 There is only one
select * from student2 where id < 4
union
select * from student2 where id > 2 and id < 6
2、union all In the end ID=3 There are two results
select * from student2 where id < 4
union all
select * from student2 where id > 2 and id < 6
Four 、 summary
union all Just merge query results , There's no de duplication or sorting , On the premise of not removing the weight , Use union all It's more efficient than union high
Link to the original text :https://blog.csdn.net/a200822146085/article/details/119545374
边栏推荐
- Repetition is the mother of skill
- [leetcode] [SQL] notes
- The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
- Matlab saves triangulation results as STL files
- How do it outsourcing resident personnel position their pain points?
- [golang] golang implements the string interception function substr
- Warmup preheating learning rate "suggestions collection"
- LVM snapshot: backup based on LVM snapshot
- Is it safe to open a stock account of Huatai Securities online?
- 异步过渡方案—Generator
猜你喜欢

QQmlApplicationEngine failed to load component qrc:/main. qml:-1 No such file or directory

Solution to the conflict between unique index and logical deletion
![Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical](/img/ce/519778cd731f814ad111d1e37abd10.png)
Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical

One revolution, two forces and three links: the "carbon reduction" road map behind the industrial energy efficiency improvement action plan

唯一性索引与逻辑删除冲突问题解决思路

Detailed explanation of conv2d -- use in arrays and images

MaxPool2d详解--在数组和图像中的应用

KubeVela 1.4:让应用交付更安全、上手更简单、过程更透明

HP notebook disable touchpad after mouse is inserted

女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
随机推荐
leetcode 474. Ones and zeroes (medium)
E-commerce seckill system
股票开户要如何办理呢?办理手机开户安全吗
Redis - 01 缓存:如何利用读缓存提高系统性能?
Doker's container data volume
Bridge emqx cloud data to AWS IOT through the public network
Ms17-010 Eternal Blue vulnerability of MSF
6-1 exploit -ftp exploit
Is it safe to buy funds on the compass?
Esp8266 becomes client and server
1175. 質數排列 / 劍指 Offer II 104. 排列的數目
C# /platform:anycpu32bitpreferred 只能与 /t:exe、/t:winexe 和 /t:appcontainerexe 一起使用
Detailed explanation of conv2d -- use in arrays and images
ABAQUS 2022 software installation package and installation tutorial
In 2022, the latest JCR officially released the list of the latest global impact factors (top 600)
Pycharm is very fast to learn from installation to full armament. There are so many pictures because it is too detailed!
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
76页智慧物流园区综合解决方案2022(附下载)
CNN classic network model details -lenet-5 (pytorch Implementation)