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

相关推荐
-雷阵雨-10 分钟前
MySQL——数据库约束
数据库·mysql
大筒木老辈子11 分钟前
MySQL笔记---C/C++访问MySQL数据库
数据库·笔记·mysql
友友马14 分钟前
『 数据库 』MySQL复习(表的约束)
数据库·mysql
奥尔特星云大使32 分钟前
MySQL分布式架构:MyCat详解
数据库·分布式·mysql·mycat·高可用
SelectDB技术团队33 分钟前
Apache Doris 内部数据裁剪与过滤机制的实现原理 | Deep Dive
大数据·数据库·apache·数据库系统·数据裁剪
像风一样!1 小时前
学习MySQL数据库的高级特性(上)
数据库·mysql
夜泉_ly2 小时前
Redis -持久化
数据库·redis·缓存
Wx-bishekaifayuan2 小时前
基于微信小程序的社区图书共享平台设计与实现 计算机毕业设计源码44991
javascript·vue.js·windows·mysql·pycharm·tomcat·php
2401_837088502 小时前
什么是NoSQL?
数据库·nosql
哎呀呦呵3 小时前
python内置模块-re模块介绍使用
java·python·mysql