Search comments or view top comments

2

Please login or register to vote for this query.

(click on this box to dismiss)

Find the top comments, or comments with specific text or by users with a specific name. Names and comment text can contain the wildcard "%".

Gardening and Landscaping Meta

Q&A about the site for gardeners and landscapers

-- UserId: User ID "zero to disable"
declare @user_id nvarchar = ##UserId:string?0##

select --top (##TopN:int?100##)
    (case when c.UserId is not null then
      'site://users/' + cast(c.UserId as nvarchar) + '|' else '' end) +
      coalesce(c.UserDisplayName, Users.DisplayName) as [User Link],
    c.Score as CommentScore,
    c.Id as [Comment Link],
    c.CreationDate
from Comments c
left join Users on Users.Id = c.UserId
where lower(Text) like '%' + lower(##text:string##) + '%'
and (##UserId## = 0 or c.UserId = ##UserId##)
order by c.Score desc, c.CreationDate desc

Enter Parameters

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