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

相关推荐
净水深流28 分钟前
中央厨房冷链技术实践:多温区改造、WMS落地与IoT温控架构
大数据·数据库·人工智能·冷库冷链
l1t42 分钟前
测试DuckDB 2.1的match_recognize模式匹配语句
数据库·duckdb
IpdataCloud2 小时前
AI智能体调用工具怎么核验来源IP?归属地、网络类型与代理风险识别(含Python代码)
数据库·python·tcp/ip
曹牧2 小时前
Java:SQL 注入漏洞
数据库
程序员JerrySUN3 小时前
Jetson Edge AI 实战01:Nano、Xavier、Orin 怎么选?Jetson 硬件选型详解【视频讲解】
java·数据库·redis·安全·mybatis
oradh3 小时前
Oracle Undo问题总结(ORA-600 [4xxx] 系列错误)
数据库·oracle
达梦数据3 小时前
DMDRS辅助表生成规则与作用
数据库·oracle
‎ദ്ദിᵔ.˛.ᵔ₎3 小时前
MySQL 表约束
数据库·mysql
Doris__HE3 小时前
【元脑服务器NF5476G7-NF5476M7技术规格分享】
运维·服务器·网络·数据库·性能优化
linmengmeng_13145 小时前
【总结】MyBatis-Plus批量插入与清表的正确姿势
java·spring boot·mysql·mybatis