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 小时前
SQL Server 查询数据库中所有表中所有字段的数据类型及长度
数据库·sql·sql server
Sunshine~L&H5 小时前
Mac 上使用 mysql -u root -p 命令,出现“zsh: command not found: mysql“?如何解决
数据库·mysql·macos
chanalbert6 小时前
数据库连接池深度研究分析报告
数据库·spring
snpgroupcn7 小时前
泰国零售巨头 CJ Express 借助 SAP 内存数据库实现高效数据管理
数据库·express·零售
FJSAY7 小时前
我自己动手写了一个MySQL自动化备份脚本,基于docker
mysql·docker·自动化
明月看潮生8 小时前
青少年编程与数学 01-011 系统软件简介 19 SSMS 数据库管理工具
数据库·青少年编程·编程与数学
一勺菠萝丶9 小时前
宝塔安装MySQL无法远程连接【已解决】
mysql
blammmp9 小时前
Redis : set集合
数据库·redis·缓存
翔云1234569 小时前
精准测量 MySQL 主从复制延迟—pt-heartbeat工具工作原理
数据库·mysql
厚衣服_39 小时前
第15篇:数据库中间件高可用架构设计与容灾机制实现
java·数据库·中间件