# Export a list of people who replied to a specific topic

**URL:** https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [25 Agosto , 2017 08:15 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756 "2017-08-25T08:15:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [25 Agosto , 2017 08:15 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/1 "2017-08-25T08:15:39Z")

</div>

Sometimes I need to mention a specific group of people who replied to a specific topic into a new one.  
That’s because I’d like to involve them into a similar discussion

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/2/a2b72bb8bc11722a0a5c4388d600dbded2ac7992.jpg)

How can I do that quickly? Is there any particular query for that?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [25 Agosto , 2017 08:57 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/2 "2017-08-25T08:57:14Z")

</div>

Why don’t you simply post in the topic, with a link to your other topic, and interested people can see and follow that link? Mentioning 26 people by `@username` seems a bit extreme.

---

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [25 Agosto , 2017 09:18 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/3 "2017-08-25T09:18:30Z")

</div>

Becuase a mention triggers a notification while just linking a topic would be overlooked  
By the way, generally I don’t have so many users and I don’t mention all the people but it’s useful to have the entire list.  
I know it would be useful just for “community” purpose so I asked if there is a quick way using some clever query

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [25 Agosto , 2017 09:44 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/4 "2017-08-25T09:44:48Z")

</div>

There is a badge query you can modify to make it work with [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin

> [@A badge granted when someone posts a reply in a single specified topic](https://meta.discourse.org/t/a-badge-granted-when-someone-posts-a-reply-in-a-single-specified-topic/276673/2):
>
> SELECT DISTINCT ON (p.user\_id) p.user\_id, p.id post\_id, p.created\_at granted\_at FROM badge\_posts p WHERE p.topic\_id = 32 AND -- 32 is the "please introduce yourself" topic (:backfill OR p.id IN (:post\_ids) ) Triggered on “edit/create a post”.

---

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [25 Agosto , 2017 09:52 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/5 "2017-08-25T09:52:52Z")

</div>

looks cool but I don’t have “badge\_posts” table.  
How can I make it work?

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [25 Agosto , 2017 10:11 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/6 "2017-08-25T10:11:43Z")

</div>

You don’t need that table because you really don’t want a badge. You want a list of users that replied to a specific topic.

Probably you need the table “users”, but I’m not a query expert…

---

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [25 Agosto , 2017 12:52 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/7 "2017-08-25T12:52:34Z")

</div>

Done 🙂 and I can download via CSV

```
SELECT u.username
FROM badge_posts p
JOIN topics t ON p.topic_id = t.id 
JOIN users u ON p.user_id = u.id
WHERE t.id = '1010'
GROUP BY p.user_id,u.username

```

---

<div class="post-metadata">

### Author: ![SidV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sidv/32/119460_2.png) [@SidV](https://meta.discourse.org/u/SidV)
#### Post date: [25 Agosto , 2017 19:00 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/8 "2017-08-25T19:00:38Z")

</div>

A little change to optimize that query (if you want to change the topic\_id before execute it)

```sql
-- [params]
-- topic_id :topic_id = 18438
SELECT u.username
FROM badge_posts p
JOIN topics t ON p.topic_id = t.id 
JOIN users u ON p.user_id = u.id
WHERE t.id = :topic_id
GROUP BY p.user_id,u.username 

```

> Note: replace 18438 for some topic\_id from your forum 😊

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 Junho , 2024 12:44 UTC](https://meta.discourse.org/t/export-a-list-of-people-who-replied-to-a-specific-topic/68756/9 "2024-06-08T12:44:24Z")

</div>

Este tópico foi automaticamente fechado após 2479 dias. Novas respostas não são mais permitidas.
