当前位置:网站首页>MySQL union和union all区别
MySQL union和union all区别
2022-07-03 10:58:00 【inexaustible】
union:对多个结果集(select语句)进行并集操作,不包括重复行,同时进行排序。
union all:对多个结果集(select语句)进行并集操作,包括重复行,不进行排序。
内部的select语句必须拥有相同数量的列,列也必须拥有相似的数据类型,同时每条select语句的列的顺序必须相同。
select A.*
from
(
SELECT 1 flag,t.id,t.name,t.status,t.task_type,u.nickname,t.create_time,t.end_time,t.start_time,t.creator
from camas_survey_task t,system_user u
where t.status = 3 and t.deleted = 0 and t.creator = u.id
union all
select 2 flag,mr.id,mr.name,mr.status,-1 task_type,u.nickname,mr.create_time,mr.end_time,mr.start_time,mr.creator
from camas_survey_monitor_rule mr,system_user u
where mr.status = 3 and mr.deleted = 0 and mr.creator = u.id
)A
order by A.start_time asc边栏推荐
- ASP.NET-酒店管理系統
- After setting up ADG, instance 2 cannot start ora-29760: instance_ number parameter not specified
- Illustrated network: what is virtual router redundancy protocol VRRP?
- Hongmeng third training (project training)
- Processes and threads
- 用了这么久线程池,你真的知道如何合理配置线程数吗?
- Multi dimensional monitoring: the data base of intelligent monitoring
- 抓包整理外篇fiddler———— 会话栏与过滤器[二]
- 2022年中南大学夏令营面试经验
- How to make others fear you
猜你喜欢

Mmc5603nj geomagnetic sensor (Compass example)

Machine learning 3.2 decision tree model learning notes (to be supplemented)

Encapsulate a koa distributed locking middleware to solve the problem of idempotent or repeated requests

基于turtlebot3实现SLAM建图及自主导航仿真

Arctangent entropy: the latest SCI paper in July 2022

Matlab extracts numerical data from irregular txt files (simple and practical)

Viewing binary bin files with notepad++ editor

导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....

活动预告 | 直播行业“内卷”,以产品力拉动新的数据增长点

(2) Base
随机推荐
Phpcms prompt message page Jump to showmessage
C language two-dimensional array
Execute kubectl on Tencent cloud container service node
LeetCode 46:全排列
Driver development based on I2C protocol
AOSP ~ NTP ( 网络时间协议 )
Hongmeng third training (project training)
Matlab extracts numerical data from irregular txt files (simple and practical)
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
Incremental database backup - DB incr DB full
STL教程8-map
Phpcms prompt message page Jump showmessage
Touch and screen automatic rotation debugging
一些常用术语
Dynamic programming (interval DP)
C语言日志库zlog基本使用
One hot code
Nestjs配置服务,配置Cookie和Session
Mysql根据时间搜索常用方法整理
The manuscript will be revised for release tonight. But, still stuck here, maybe what you need is a paragraph.