为何Union All把相同的记录去除了?

中关村网名 中关村网名 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Use tempdb;
Go
Create table [dbo].[a] (name varchar null);
Create table [dbo].[b] (name varchar null);
Create table [dbo].[c] (name varchar null);
Insert Into [dbo].[a] values ('a'),('b'),('c');
Insert Into [dbo].[b] values ('a'),('d'),('c');
Insert Into [dbo].[c] values ('a'),('e'),('f');
GO
Select name From dbo.a
except (
Select name From dbo.a
Intersect
Select name From dbo.b
Intersect
Select name From dbo.c
)
Union All
Select name From dbo.b
except (
Select name From dbo.a
Intersect
Select name From dbo.b
Intersect
Select name From dbo.c
)
Union All
Select name From dbo.c
except (
Select name From dbo.a
Intersect
Select name From dbo.b
Intersect
Select name From dbo.c
)

明明应该有6条记录,以上代码返回5条记录,把相同name的c记录去掉了,为何呢??
...全文
评论 7
收藏 已收藏
分享
返回顶部
中关村网名
应用实例 27,579 成员 68,540 内容