Related Tags

12

Please login or register to vote for this query.

(click on this box to dismiss)

Gets the most commonly associated tags to a particular tag, by number of posts.

Mi Yodeya Meta

Q&A about the site for those who base their lives on Jewish law and tradition and anyone interested in learning more

SELECT 
  Tags.TagName AS [Tag Name], 
  COUNT(*) AS [Number of associated posts]
FROM PostTags
  INNER JOIN Tags
    ON Tags.Id = PostTags.TagId
WHERE 
  PostTags.PostId IN 
  (
    --Gets all the PostIds that have this tag
    SELECT DISTINCT PostId
    FROM PostTags
      INNER JOIN Tags
        ON Tags.Id = PostTags.TagId
    WHERE Tags.TagName = ##TagName:string##
  )
  AND Tags.TagName <> ##TagName:string##--Remove the tag your looking for from "related" search results.
GROUP BY Tags.TagName
ORDER BY COUNT(*) DESC

Enter Parameters

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