# Receive a badge for a post into a topic containing specific tag

**URL:** https://meta.discourse.org/t/receive-a-badge-for-a-post-into-a-topic-containing-specific-tag/35397
**Category:** Support
**Created:** [9 november 2015 om 21:07 UTC](https://meta.discourse.org/t/receive-a-badge-for-a-post-into-a-topic-containing-specific-tag/35397 "2015-11-09T21:07:42Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [31 mei 2016 om 18:55 UTC](https://meta.discourse.org/t/receive-a-badge-for-a-post-into-a-topic-containing-specific-tag/35397/5 "2016-05-31T18:55:20Z")

</div>

Just a note that since [Tagging support is now part of discourse](https://meta.discourse.org/t/tagging-support-is-now-part-of-discourse/43334), the way to create a badge for a post with a given tag has changed.

The code now should look like this:

```plaintext
SELECT p.user_id, min(p.created_at) granted_at, MIN(p.id) post_id
FROM badge_posts p
JOIN topics t ON t.id = p.topic_id
JOIN topic_tags tt on t.id = tt.topic_id
JOIN tags on tags.id = tt.tag_id
WHERE category_id = (
  SELECT id FROM categories WHERE name ilike 'CATEGORY-NAME'
) AND p.post_number = 1
AND tags.name LIKE 'TAG-NAME'
and (:backfill OR ( p.id IN (:post_ids) ))
GROUP BY p.user_id

```

Changing all of your Badge Queries is left as an exercise to the admin. 🙂

(But I’ve got dozens of badges to change, so I’ll probably have a script that will fix at least mine Real Soon Now. If you’re interested, let me know and I’ll endeavor to make it useful for others.)

---

_[View the full topic](https://meta.discourse.org/t/receive-a-badge-for-a-post-into-a-topic-containing-specific-tag/35397)._
