假设有表(UserTB):
1、Union(不允许重复)
SELECT * FROM dbo.UserTB WHERE deptId IN ( 1, 3 ) UNION SELECT * FROM dbo.UserTB WHERE deptId IN ( 1, 2 )结果:
2、Union All(允许重复)
SELECT * FROM dbo.UserTB WHERE deptId IN ( 1, 3 ) UNION ALL SELECT * FROM dbo.UserTB WHERE deptId IN ( 1, 2 )结果: