"database" tag posts with other non-DBMS tags

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

DECLARE @DatabaseTag INT = 2;

SELECT DISTINCT
  dbtag.PostId AS [Post Link]
, Posts.Tags AS [Tags]
, Posts.CreationDate AS 'Creation Date'
  
FROM PostTags AS dbtag
  INNER JOIN PostTags AS othertags
    ON dbtag.PostId = othertags.PostId
    AND dbtag.TagId = @DatabaseTag
    AND othertags.TagId <> @DatabaseTag
  INNER JOIN Tags
    ON othertags.TagId = Tags.Id
  INNER JOIN Posts
    ON dbtag.PostId = Posts.Id

WHERE Posts.Id NOT IN (
    SELECT 
      pt.PostId
    FROM Tags t
      INNER JOIN PostTags pt
        ON t.Id = pt.TagId
    WHERE
      t.TagName LIKE '%sql%'
      OR t.TagName LIKE '%db'
      OR t.TagName = 'db2'
  )
/*
WHERE Posts.Tags NOT LIKE '%sql%'
  AND Posts.Tags NOT LIKE '%db%'
  AND Posts.Tags NOT LIKE '%db2%'
ORDER BY Posts.CreationDate DESC;
*/

Enter Parameters

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