假设有表(usertb): 1、union(不允许重复) ? 1 2 3 4 5 6 7 select * from dbo.usertb where deptid in ( 1, 3 ) union select * from dbo.usertb where deptid in ( 1, 2 ) 结果: 2、union all(允许重复) ? 1 2 3 4 5 6 7 select * from dbo.usertb wher
假设有表(usertb):
1、union(不允许重复)
?
1
2
3
4
5
6
7
select *
from dbo.usertb
where deptid in ( 1, 3 )
union
select *
from dbo.usertb
where deptid in ( 1, 2 )
结果:
2、union all(允许重复)
?
1
2
3
4
5
6
7
select *
from dbo.usertb
where deptid in ( 1, 3 )
union all
select *
from dbo.usertb
where deptid in ( 1, 2 )
结果: