MySQL查询篇-集合运算

文章目录

  • [union (并集)](#union (并集))
    • [union distinct](#union distinct)
    • [union all](#union all)
  • intersect(交集)
    • [intersect all](#intersect all)
    • [intersect distinct](#intersect distinct)
  • [except 差集](#except 差集)
    • [except distinct](#except distinct)
    • [except distinct](#except distinct)
    • [except all](#except all)

union (并集)

union distinct

使用前提:a和c数据类型一致,b和d数据类型一致,查询的两个结果集列数也得相同

默认的union 即为union distinct

复制代码
select a,b from table1
union
select c,d from table2;

union all

并集不去重

MySQL只支持union

intersect(交集)

intersect all

intersect distinct

except 差集

except distinct

except 差集

except distinct

except all

相关推荐
不知更鸟2 小时前
Django 项目是什么
数据库·sqlite
有一个好名字5 小时前
MyBatis-Plus 三种数据库操作方式详解 + 常用方法大全
数据库·mybatis
-Xie-5 小时前
Redis(八)——多线程与单线程
java·数据库·redis
抛砖者5 小时前
1、Ubuntu上MySQL安装,密码设置,远程访问,端口修改
mysql·ubuntu
G探险者5 小时前
为什么 VARCHAR(1000) 存不了 1000 个汉字? —— 详解主流数据库“字段长度”的底层差异
数据库·后端·mysql
Albert Tan6 小时前
Oracle EBS R12.2.14 清理FND_LOBS并释放磁盘空间
数据库·oracle
L.EscaRC6 小时前
图数据库Neo4j原理与运用
数据库·oracle·neo4j
知己80806 小时前
docker搭建图数据库neo4j
数据库·docker·neo4j
TDengine (老段)6 小时前
什么是 TDengine IDMP?
大数据·数据库·物联网·时序数据库·tdengine·涛思数据
j***82707 小时前
【玩转全栈】----Django连接MySQL
android·mysql·django