Comment search

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

SELECT p.Id AS [Post Link], p.Score AS 'Post Score',
  COALESCE(p.Tags, q.Tags) AS Tags,
  p.CreationDate, p.OwnerUserId AS [User Link],
  c.Id AS [Comment Link], c.Score,
  c.CreationDate, c.UserId AS [User Link]
  FROM Comments AS c
  INNER JOIN Posts AS p
    ON c.PostId = p.Id
  LEFT OUTER JOIN Posts AS q
    ON q.Id = p.ParentId
  WHERE c.Text COLLATE SQL_Latin1_General_CP1_CI_AS 
               LIKE '%' + ##query:string## + '%'
    AND p.PostTypeId = ##postTypeId:int?1##
-- postTypeId: 1 = questions, 2 = answers
  ORDER BY c.Score DESC

Enter Parameters

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