declare @postid int = ##postid:int## declare @userid int ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @postid int = ##postid:int##
declare @userid int = ##userid:int##

select c.id as [Comment Link]
     , c.postid as [Post Link]
from comments c
inner join posts p on p.id = c.postid
where ( p.id = @postid
or p.parentid = @postid)
and c.userid = @userid
union
select null
     , id
from posts p
where (p.id = @postid
or p.parentid = @postid)
and p.owneruserid = @userid

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results