Q&A about the site for enthusiasts and scholars of mythology and folklore
-- @PostId -> need to know id of post DECLARE @PostId int = ##PostId## SELECT DISTINCT p.Id, p.Title, p.Tags FROM Posts p INNER JOIN PostTags pt ON p.Id = pt.PostId WHERE NOT EXISTS ( SELECT 1 FROM PostTags pt2 WHERE pt2.PostId = @PostId AND pt2.TagId NOT IN ( SELECT pt3.TagId FROM PostTags pt3 WHERE pt3.PostId = p.Id ) )