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

相关推荐
IpdataCloud4 分钟前
跨境支付如何识别高风险IP?用IP风险画像服务选型与集成指南
服务器·网络·数据库·tcp/ip·安全
agilearchitect9 分钟前
asyncpg:专为 asyncio 打造的 PostgreSQL 驱动
数据库·其他·postgresql
Adorable老犀牛15 分钟前
MySQL Server Exporter:Prometheus 监控 MySQL/MariaDB 指南
mysql·prometheus·mariadb
凡人叶枫24 分钟前
Effective C++ 条款08:别让异常逃离析构函数
java·linux·数据库·c++·嵌入式开发
herinspace30 分钟前
管家婆财工贸软件中关于价格常见问题小结
服务器·网络·数据库·电脑·管家婆软件
北风toto1 小时前
本体和智能体协同核心5步骤(生成sql语句)
数据库·sql
IvorySQL1 小时前
PostgreSQL 技术日报 (6月10日)|多工具版本更新,PG19 图语法落地
数据库·postgresql
lsyeei1 小时前
数据库分库分表
数据库
这个DBA有点耶1 小时前
Vibe Coding 是什么?当“感觉编程”遇上数据库
数据库·人工智能·架构·学习方法·ai编程·程序员创富·改行学it
范什么特西1 小时前
重点:mybatis注意细节
java·mysql·mybatis