# Linking badge sql to a topic id?

**URL:** https://meta.discourse.org/t/linking-badge-sql-to-a-topic-id/404943
**Category:** Support
**Tags:** sql-triggered-badge
**Created:** [June 10, 2026, 12:54pm UTC](https://meta.discourse.org/t/linking-badge-sql-to-a-topic-id/404943 "2026-06-10T12:54:20Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [June 10, 2026, 12:54pm UTC](https://meta.discourse.org/t/linking-badge-sql-to-a-topic-id/404943/1 "2026-06-10T12:54:20Z")

</div>

I have this SQL in the settings of a badge and it awards a badge to anyone that gets added to the `beta-testers` group:

```plaintext
SELECT u.id AS user_id, CURRENT_TIMESTAMP AS granted_at
FROM users u
INNER JOIN group_users gu ON gu.user_id = u.id
INNER JOIN groups g ON g.id = gu.group_id
WHERE g.name = 'beta-testers'

```

Can I modify that to also link the badge to a specific topic ID? 🤔

---

_[View the full topic](https://meta.discourse.org/t/linking-badge-sql-to-a-topic-id/404943)._
