Orig-Dupe pairs with disjunct tags

1

Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts

Q&A for enthusiasts and power users of the Android operating system

SELECT
  Orig.Id AS OrigId,
  Orig.Id AS [Post Link],
  Orig.Tags AS OrigTags,
  Orig.ViewCount AS OrigViewCount,
  Dupe.Id AS DupeId,
  Dupe.Id AS [Post Link],
  Dupe.Tags AS DupeTags,
  Dupe.ViewCount AS DupeViewCount
FROM PostLinks, Posts Orig, Posts Dupe
WHERE PostLinks.Id NOT IN (
  SELECT PostLinks.Id
  FROM PostLinks, PostTags DupeTags, PostTags OrigTags
  WHERE
    PostLinks.LinkTypeId = 3
    AND
    DupeTags.PostId = PostLinks.PostId
    AND
    PostLinks.RelatedPostId = OrigTags.PostId
    AND
    DupeTags.TagId = OrigTags.TagId
)
  AND
  Orig.Id = PostLinks.RelatedPostId
  AND
  Dupe.Id = PostLinks.PostId
  AND
  PostLinks.LinkTypeId = 3
ORDER BY Orig.ViewCount + Dupe.ViewCount DESC;

Enter Parameters

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