# Creating custom badge with custom rules

**URL:** <https://meta.discourse.org/t/creating-custom-badge-with-custom-rules/257688>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [March 10, 2023, 11:27am UTC](https://meta.discourse.org/t/creating-custom-badge-with-custom-rules/257688 "2023-03-10T11:27:22Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)\
**Post date:** [March 13, 2023, 3:03pm UTC](https://meta.discourse.org/t/creating-custom-badge-with-custom-rules/257688/6 "2023-03-13T15:03:07Z")

</div>

This is a SQL code of “Trigger: Update daily”;

```sql
SELECT st.user_id user_id, current_timestamp granted_at
FROM user_stats st
JOIN users u
ON st.user_id = u.id
WHERE st.post_count >= 2 AND st.likes_given >= 1 AND u.uploaded_avatar_id > 0

```

The other triggers depend on something specific, and I don’t recommend using them unless you find a SQL expert. (I’m not familiar with SQL myself

---

_[View the full topic](https://meta.discourse.org/t/creating-custom-badge-with-custom-rules/257688)._
