# Badge query request: Received X likes in topic containing specific tag

**URL:** <https://meta.discourse.org/t/badge-query-request-received-x-likes-in-topic-containing-specific-tag/27901>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [April 24, 2015, 11:35am UTC](https://meta.discourse.org/t/badge-query-request-received-x-likes-in-topic-containing-specific-tag/27901 "2015-04-24T11:35:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)\
**Post date:** [April 24, 2015, 3:08pm UTC](https://meta.discourse.org/t/badge-query-request-received-x-likes-in-topic-containing-specific-tag/27901/2 "2015-04-24T15:08:15Z")

</div>

```sql
select p.id, p.user_id, count(u.id)
from posts p
  left join post_uploads pu on p.id = pu.post_id
  left join uploads u on pu.upload_id = u.id 
where u.original_filename similar to '%.(jpg|png|)'
group by p.id, p.user_id
  having count(u.id) > 1

```

This finds all posts with at least two uploads that are images (end in either `.jpg` or `.png`).

---

_[View the full topic](https://meta.discourse.org/t/badge-query-request-received-x-likes-in-topic-containing-specific-tag/27901)._
