加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

union、union all的用法和区别

发布时间:2020-12-12 14:46:22 所属栏目:百科 来源:网络整理
导读:接触到了几次union、union all,又一次挖坑了,总结一下两者的使用和区别: 1.union去重 2.union自动排序 3.因为union去重,故效率不如union all。若没有重复数据且不要求排序,可以用union all 实例: 1. select id from test1 where id5 and id10 union se

接触到了几次union、union all,又一次挖坑了,总结一下两者的使用和区别: 1.union去重 2.union自动排序 3.因为union去重,故效率不如union all。若没有重复数据且不要求排序,可以用union all

实例: 1.

select id from test1 where id>5 and id<10

union

select id from test1 where id<8;

结果:

select id from test1 where id>5 and id<10

union all

select id from test1 where id<8;

结果:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读