Q&A about the site for professors, theologians, and those interested in exegetical analysis of biblical texts
WITH PostTagsWithActiveSourceTag (PostId, SourceTagName, SourceTagId, TargetTagName, TargetTagId) AS ( SELECT pt.PostId, ts.SourceTagName, st.Id, ts.TargetTagName, tt.Id FROM TagSynonyms ts JOIN Tags st ON ts.SourceTagName = st.TagName JOIN Tags tt ON ts.TargetTagName = tt.TagName JOIN PostTags pt ON st.Id = pt.TagId WHERE ApprovedByUserId IS NOT NULL ) SELECT t.PostId AS [Post Link], t.SourceTagName, t.TargetTagName FROM PostTagsWithActiveSourceTag t LEFT JOIN PostTags pt ON ( t.PostId = pt.PostId AND t.TargetTagId = pt.TagId ) WHERE pt.TagId IS NULL AND t.SourceTagName = '##SourceTagName##'