# How to list emails for users in a group?

**URL:** https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [December 15, 2020, 1:57am UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323 "2020-12-15T01:57:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [December 15, 2020, 1:57am UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323/1 "2020-12-15T01:57:24Z")

</div>

Just that. There is a way to e-mail all the group or list the email of entire _custom_ group?

Thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 15, 2020, 6:45am UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323/2 "2020-12-15T06:45:26Z")

</div>

One way is to use the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin.

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [December 16, 2020, 4:46pm UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323/3 "2020-12-16T16:46:31Z")

</div>

> [@pfaffman](#):
>
> [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin

I can do it from SQL right? I have access to the server. Maybe you can share the query to display that input?

Thanks for your quick reply.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 16, 2020, 4:48pm UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323/4 "2020-12-16T16:48:28Z")

</div>

The [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin offers some support in building such queries. It’s a little complicated, as you need to join a couple tables to get the email address. It’s beyond what I have time for, but there might be examples in the [data explorer](https://meta.discourse.org/t/32566?silent=true) category.

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [September 10, 2026, 10:42pm UTC](https://meta.discourse.org/t/how-to-list-emails-for-users-in-a-group/173323/5 "2026-09-10T22:42:09Z")

</div>

That’s the Query Explorer code to run. It shows a selector to choose between all the groups and it can be used with Workflows and the entire Discourse system.

```plaintext
-- [params]
-- group_id :group_id

WITH user_groups AS (
    SELECT gu.user_id
    FROM groups g
    JOIN group_users gu ON gu.group_id = g.id
    WHERE g.id = :group_id
    GROUP BY gu.user_id
)
SELECT ue.email
FROM users u
INNER JOIN user_emails ue ON u.id = ue.user_id
INNER JOIN user_groups ug ON u.id = ug.user_id
WHERE u.id > 0
ORDER BY u.id DESC

```
