一、区别1:
1、union: 对两个结果集进行并集 *** 作, 不包括重复行,相当于distinct;
2、union all: 对两个结果集进行并集 *** 作,, 不管是不是重复;
二、区别2:
1、union: 会对获取的结果进行排序 *** 作
2、union all: 不会对获取的结果进行排序 *** 作
三、区别3:
1、union看到结果中ID=3的只有一条(这里不会把id=3去重了一个)
select * from student where id < 4
union
select * from student2 where id > 2 and id < 6
2、union all 结果中ID=3的结果有两个
select * from student where id < 4
union all
select * from student2 where id > 2 and id < 6
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)