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

相关推荐
java_logo8 小时前
Kubernetes Dashboard Docker 容器化部署指南
运维·mysql·docker·云原生·容器·kubernetes·php
一 乐8 小时前
农产品电商|基于SprinBoot+vue的农产品电商系统(源码+数据库+文档)
java·前端·javascript·数据库·vue.js·spring boot
TDengine (老段)9 小时前
TDengine IDMP 赋能新能源:光伏电站智能运维实践
大数据·运维·数据库·物联网·时序数据库·tdengine·涛思数据
Chan169 小时前
热点数据自动缓存方案:基于京东 Hotkey 实践
java·数据库·redis·mysql·spring·java-ee·intellij-idea
Leisure -_-9 小时前
Oracle Database 26ai Free 安装讲解
数据库·oracle
i***71959 小时前
如何查看PostgreSQL的版本
数据库·postgresql
妮妮喔妮10 小时前
pai 的redis存储
数据库·redis·缓存
SelectDB10 小时前
Apache Doris AI 能力揭秘(三):AI_AGG 与 EMBED 函数深度解析
数据库·后端·apache
普通网友10 小时前
用Python批量处理Excel和CSV文件
jvm·数据库·python
y***613110 小时前
在Spring Boot项目中使用MySQL数据库
数据库·spring boot·mysql