# Executing SQL doesn't work in psql

**URL:** <https://meta.discourse.org/t/executing-sql-doesnt-work-in-psql/130054>\
**Category:** Self-hosting\
**Created:** [October 2, 2019, 3:54pm UTC](https://meta.discourse.org/t/executing-sql-doesnt-work-in-psql/130054 "2019-10-02T15:54:29Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)\
**Post date:** [October 2, 2019, 3:54pm UTC](https://meta.discourse.org/t/executing-sql-doesnt-work-in-psql/130054/1 "2019-10-02T15:54:30Z")

</div>

I’m trying to execute:

```sql
SELECT user_id, 0 post_id, current_timestamp granted_at 
FROM badge_posts  
WHERE (:backfill OR user_id IN (:user_ids) OR 0 NOT IN (:post_ids) )
GROUP BY user_id 
HAVING count(*) > 1000

```

but I’m getting an error on :backfill. Can anyone tell me why?

 ![58](https://global.discourse-cdn.com/meta/original/3X/3/9/39c3344a1b8db2263f07c04540549e9a41feed9a.jpeg)

I know this SQL used to run in badge creation.

---

_[View the full topic](https://meta.discourse.org/t/executing-sql-doesnt-work-in-psql/130054)._
