有人能告诉我为什么当我为 [PropertyId] 添加额外的连接信息时返回 0 条记录吗?我知道这很简单,但是我不知所措。
declare @ViewId as int;
set @ViewId = 11;
with Views
as
(
select [LiveWireView].[Id], [LiveWireView].[Name], [LiveWireView].[ParentId], [PropertyToViewMap].[PropertyId]
from [LiveWireView]
inner join [PropertyToViewMap] on [PropertyToViewMap].[ViewId] = [LiveWireView].[Id]
where [LiveWireView].[Id] = @ViewId
union all
select [v].[Id], [v].[Name], [v].[ParentId], [p].[PropertyId]
from [LiveWireView] v
inner join [PropertyToViewMap] p on [p].[ViewId] = [v].[Id]
inner join Views on Views.Id = v.ParentId
)
select [PropertyId] from Views;