# Badges predicated on getting a series of other badges?

**URL:** <https://meta.discourse.org/t/badges-predicated-on-getting-a-series-of-other-badges/22471>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [2014 年11 月 24 日 17:36 UTC](https://meta.discourse.org/t/badges-predicated-on-getting-a-series-of-other-badges/22471 "2014-11-24T17:36:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

作者： ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
发布日期： [2014 年11 月 24 日 18:45 UTC](https://meta.discourse.org/t/badges-predicated-on-getting-a-series-of-other-badges/22471/3 "2014-11-24T18:45:10Z")

</div>

Proof of concept: Award a badge to anyone with badges 106, 107, and 108.

```plaintext
SELECT user_id, CURRENT_TIMESTAMP granted_at, NULL post_id
FROM user_badges pb
WHERE badge_id = 106
AND EXISTS (
  SELECT 1 FROM user_badges ib
  WHERE pb.user_id = ib.user_id
  AND ib.badge_id = 107
)
AND EXISTS (
  SELECT 1 FROM user_badges ib
  WHERE pb.user_id = ib.user_id
  AND ib.badge_id = 108
)
;

```

---

_[View the full topic](https://meta.discourse.org/t/badges-predicated-on-getting-a-series-of-other-badges/22471)._
