# Badges based on User Custom Fields?

**URL:** https://meta.discourse.org/t/badges-based-on-user-custom-fields/276719
**Category:** Data & reporting
**Tags:** sql-triggered-badge, user-custom-fields
**Created:** [2015年二月18日 20:47 UTC](https://meta.discourse.org/t/badges-based-on-user-custom-fields/276719 "2015-02-18T20:47:17Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2015年二月21日 21:03 UTC](https://meta.discourse.org/t/badges-based-on-user-custom-fields/276719/4 "2015-02-21T21:03:39Z")

</div>

I think you’d simply add the following:

```sql
AND EXISTS (
  SELECT 1 FROM user_badges ib
  WHERE cf.user_id = ib.user_id
  AND ib.badge_id = 888
)

```

Where **888** is the badge ID number of the other prerequisite badge. See the following for details:

> [@Badges predicated on getting a series of other badges?](https://meta.discourse.org/t/badges-predicated-on-getting-a-series-of-other-badges/22471):
>
> Story: As an admin, I’d like to create a badge that is automatically granted if (and only if) a user has received a certain list of other badges, so that we can create a list of accomplishments/tasks in our community, and a title/role when certain of those items are achieved. Is this possible within the current system and SQL, or does there need to be some notion of “sub-badges” to accomplish something like this?

---

_[View the full topic](https://meta.discourse.org/t/badges-based-on-user-custom-fields/276719)._
