sql 案例 目的:把两个sql合并成一个sql,union和union all 用法

  • Post author:
  • Post category:其他




其他sql格式也在更新中,可直接查看这个系列,要是没有你需要的格式,可在评论或私信我



个人目录




sql案例场景
select id as id  from a where id=1

在这里插入图片描述



union 的案例
  1. 对两个结果集进行并集操作,不包括重复行,去重
  2. 会对获取的结果进行排序操作
select id as id  from a where id=1
union 
select id as id  from a where id=1

在这里插入图片描述



union all 的案例
  1. 对两个结果集进行并集操作,包括重复行,不去重
  2. 不会对获取的结果进行排序操作
select id as id  from a where id=1
union all 
select id as id  from a where id=1

在这里插入图片描述



版权声明:本文为zzydan0原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。