我编写了一个 StackExchange DataExplorer 查询来按 User.Id 列出所有评论
该查询有效并返回Id
s ofquestions
和answers
。我不明白为什么answers
第二列是空的。
DECLARE @UserId int = ##UserId##
Select p.Id
, '<a href=https://stackoverflow.com/questions/'
+ Cast(p.Id as varchar(20)) + '>'
+ Cast(p.Id as varchar(20))
+ ' - ' + p.Title + '</a>'
, c.Text
FROM Users u
Join Comments c ON c.UserId = @UserId
JOIN Posts p ON p.Id = c.PostId
where u.Id = @UserId AND p.Id IS NOT NULL
即使假设该p.Title
列为 NULL,该列p.Id
也不是 NULL,因此我希望这部分
'<a href=https://stackoverflow.com/questions/'
+ Cast(p.Id as varchar(20)) + '>'
+ Cast(p.Id as varchar(20))
+ ' - ' + p.Title + '</a>'
会根据这个问题返回一些东西。但是第二列完全是空的。
为什么会这样?