I have written a StackExchange DataExplorer query to list all comments by User.Id
The query works and returns Id
s of questions
and answers
. What I do not understand is
why, for answers
, the second column is empty.
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
Even assuming that the column p.Title
is NULL the column p.Id
is not NULL and I would therefore expect that this part
'<a href=https://stackoverflow.com/questions/'
+ Cast(p.Id as varchar(20)) + '>'
+ Cast(p.Id as varchar(20))
+ ' - ' + p.Title + '</a>'
would return something as per this question. But the second column is totally empty.
Why is that the case?