Finds Posts with images ranked by score

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping Meta

Q&A about the site for gardeners and landscapers

--Finds Posts with images ranked by score
DECLARE @IL VARCHAR(MAX)
SET @IL = 'http://i.imgur.com/'

SELECT TOP 5
  Score AS "Score",
  Id AS [Post Link],
  SUBSTRING(Body,
            CHARINDEX(@IL,Body),
            CHARINDEX(' ',Body,CHARINDEX(@IL,Body))-CHARINDEX(@IL,Body)-1) AS [Image Link]
FROM
  Posts
WHERE
  PostTypeId = 2 AND
  Body LIKE '%' + @IL + '%'
ORDER BY
  Score DESC

Enter Parameters

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