comments mentioning a username (well, a string)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

declare @usermatch nvarchar(100);
set @usermatch = '%' + lower(##username:string##) + '%';

select
  q.viewcount,
  p.creationdate,
  c.score as cScore,
  p.score as pScore,
  q.score as qScore,
  iif(p.posttypeid = 2, 'a', 'q') as [q/a],
  c.id as [Comment Link]
from comments c
  join posts p
  on c.postid = p.id
  join posts q
  on iif(p.parentid > 0, p.parentid, p.id) = q.id
where lower(c.text) like @usermatch
order by q.viewcount desc

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results