# "Sorry, An error has occurred" when changing a badge sql trigger to "When a user is edited or created"

**URL:** <https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061>\
**Category:** Bug\
**Created:** [21 Maggio 2015, 7:46am UTC](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061 "2015-05-21T07:46:32Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![db0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/db0/32/116141_2.png) [@db0](https://meta.discourse.org/u/db0)\
**Post date:** [21 Maggio 2015, 10:20am UTC](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061/11 "2015-05-21T10:20:47Z")

</div>

This seems to work (I removed the ‘u’ table from the FROM)

```
SELECT cf.user_id user_id, cf.updated_at granted_at
FROM user_custom_fields cf
WHERE cf.name = 'user_field_2'
AND (
  cf.user_id IN (:user_ids)
  OR :backfill
)
AND length(cf.value) > 1

```

---

_[View the full topic](https://meta.discourse.org/t/sorry-an-error-has-occurred-when-changing-a-badge-sql-trigger-to-when-a-user-is-edited-or-created/29061)._
