검색에서 와일드카드 태그 사용 - 특정 태그가 없는 주제 찾기?

Data Explorer 쿼리를 사용하여 특정 태그가 하나만 있는 주제 목록을 가져올 수 있습니다. 다음과 같은 쿼리가 도움이 될 수 있습니다:

--[params]
-- string :tag_name

with tagged_topics AS (
SELECT 
topic_id
FROM topic_tags
JOIN tags
ON tags.id = topic_tags.tag_id
WHERE tags.name = :tag_name
),
counts AS (
SELECT
COUNT(id) AS tag_count,
tagged_topics.topic_id
FROM topic_tags
JOIN tagged_topics
ON tagged_topics.topic_id = topic_tags.topic_id
GROUP BY tagged_topics.topic_id
)

SELECT
c.topic_id
FROM counts c
JOIN topics t
ON t.id = c.topic_id
WHERE t.deleted_at IS NULL
AND t.archetype = 'regular'
AND c.tag_count = 1
1개의 좋아요