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

相关推荐
亭台烟雨中23 分钟前
SQL优化简单思路
数据库·sql
老华带你飞2 小时前
畅阅读小程序|畅阅读系统|基于java的畅阅读系统小程序设计与实现(源码+数据库+文档)
java·数据库·vue.js·spring boot·小程序·毕设·畅阅读系统小程序
Codeking__3 小时前
mysql基础——库与表的操作
数据库·mysql
_苏沐4 小时前
cte功能oracle与pg执行模式对比
数据库·oracle
silver98865 小时前
再谈golang的sql链接dsn
mysql·golang
qq_508823408 小时前
金融数据库--3Baostock
数据库·金融
悦数图数据库8 小时前
图技术重塑金融未来:悦数图数据库如何驱动行业创新与风控变革
数据库·金融
九河云8 小时前
华为云 GaussDB:金融级高可用数据库,为核心业务保驾护航
网络·数据库·科技·金融·华为云·gaussdb
老华带你飞9 小时前
租房平台|租房管理平台小程序系统|基于java的租房系统 设计与实现(源码+数据库+文档)
java·数据库·小程序·vue·论文·毕设·租房系统管理平台
ouou061711 小时前
企业级NoSql数据库Redis集群
数据库·redis·nosql