Find posts where X is the only tag


Please login or register to vote for this query.

(click on this box to dismiss)

Finds posts where (user input) is the only tag. No results means that the tag is never used stand-alone, and might be a meta-tag.

Stack Overflow

Q&A for professional and enthusiast programmers

declare @targetTagId int;

select @targetTagId = t.Id
from Tags t
where t.TagName = '##TargetTagName##';

;with QuestionsWithTargetTag as
  select p.Id
  from Posts p
  inner join PostTags pt on p.Id = pt.PostId and pt.TagId = @targetTagId
  where p.PostTypeId = 1 --question
select qwtt.Id [Post Link]
from QuestionsWithTargetTag qwtt
inner join Posts p on p.Id = qwtt.Id
where p.Id not in (
  select qwtt2.Id
  from QuestionsWithTargetTag qwtt2
  inner join PostTags pt on qwtt2.Id = pt.PostId and pt.TagId != @targetTagId)

Enter Parameters

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