首页 > 其他 > 详细

union和union all的区别

时间:2015-04-20 09:16:35      阅读:306      评论:0      收藏:0      [点我收藏+]

一、引言

union关键字用来连接多个结果集,union和union all的区别在于:union 对两个结果集进行并集操作,重复数据只显示一次;Union All,对两个结果集进行并集操作,重复数据全部显示。

二、测试步骤

1.student表

技术分享

2.union

select * from stu where stuNo <= b10050505
union
select * from stu where stuNo >= b10050505

技术分享

3.union all

select * from stu where stuNo <= b10050505
union all
select * from stu where stuNo >= b10050505

技术分享

三、结论

可以发现使用union进行连接的结果集没有重复数据b10050505,而使用union all进行连接的结果集中含有重复数据b10050505

 

union和union all的区别

原文:http://www.cnblogs.com/lit10050528/p/4440612.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!