# 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:** 5

<div class="post-metadata">

### Author: ![Kushalghosh9899](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kushalghosh9899/32/292844_2.png) [@Kushalghosh9899](https://meta.discourse.org/u/Kushalghosh9899)
#### Post date: [March 13, 2023, 6:44am UTC](https://meta.discourse.org/t/creating-custom-badge-with-custom-rules/257688/5 "2023-03-13T06:44:59Z")

</div>

I have installed the plugin and made the below SQL command which is giving me the users who are fulfilling these 3 rules but I don’t know how to convert it into a trigger when an user acts on the post.

SQL command -  
`select users.username, user_stats.user_id from user_stats Inner Join users ON user_stats.user_id = users.id where post_count = 2 AND likes_given = 1 AND uploaded_avatar_id > 0`

Following this post [Creating triggered custom badge queries](https://meta.discourse.org/t/create-triggered-custom-badge-queries/19336) but still unable to create because I am really new to the discourse.

Kindly help me out to fix this, if I can complete this once then I can build my other own custom badges too with less friction.  
@Lhc_fl

---

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