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常用函数
数据库·sql
道长没有道观2 分钟前
mysql database learn
数据库·mysql
code_li4 分钟前
多数据高性能 同步 到本地数据库表里
数据库
一个天蝎座 白勺 程序猿11 分钟前
Apache IoTDB(18):IoTDB时序数据库的数据同步之Pipe机制与插件同步指南
数据库·apache·时序数据库·iotdb
颜颜yan_13 分钟前
告别“子查询性能陷阱“:金仓数据库智能下推优化器的设计与实测
数据库·oracle
sdanss16 分钟前
MySQL——表的约束
数据库·mysql
吾诺16 分钟前
MySQL远程连接错误解决:“Host is not allowed to connect to this MySQL server”详解
数据库·mysql
耶叶17 分钟前
Android开发:用户注册和登录的数据库代码详细解释
android·数据库·kotlin
xuansec32 分钟前
【PortSwigger】SQL注入第一题:WHERE 子句注入漏洞利用 —— 检索隐藏数据
数据库·sql
X-⃢_⃢-X32 分钟前
二、索引的数据结构
数据结构·mysql