# Tags curinga em buscas - encontrar tópicos sem certas tags?

**URL:** <https://meta.discourse.org/t/wildcard-tags-in-searches-finding-topics-without-certain-tags/130633>\
**Category:** Feature\
**Tags:** search\
**Created:** [Outubro 9, 2019, 11:22pm UTC](https://meta.discourse.org/t/wildcard-tags-in-searches-finding-topics-without-certain-tags/130633 "2019-10-09T23:22:15Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [Outubro 13, 2019, 4:45pm UTC](https://meta.discourse.org/t/wildcard-tags-in-searches-finding-topics-without-certain-tags/130633/6 "2019-10-13T16:45:21Z")

</div>

Você pode obter uma lista de tópicos que possuem apenas uma tag específica usando uma consulta no [Data Explorer](https://meta.discourse.org/t/32566?silent=true). Algo como este exemplo pode funcionar para você:

```sql
--[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

```

---

_[View the full topic](https://meta.discourse.org/t/wildcard-tags-in-searches-finding-topics-without-certain-tags/130633)._
