# A list of all channels with all users in them

**URL:** <https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196>\
**Category:** Troubleshooting\
**Created:** [July 28, 2020, 11:57am UTC](https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196 "2020-07-28T11:57:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VincentVegas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/vincentvegas/32/5103_2.png) [@VincentVegas](https://forum.mattermost.com/u/VincentVegas)\
**Post date:** [July 28, 2020, 11:57am UTC](https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196/1 "2020-07-28T11:57:45Z")

</div>

Hello.

Over the years, our colleagues have created many private channels where they communicate with specific people. Now my boss wants to know which channels are used by whom and which channels are unused and can be deleted. Since no one is in all groups, this probably has to be done through the CLI. Is there a simple and nice solution for this?  
The output should look something like this:

- Channel1  
User 1  
User 2  
User 3
- Channel 2  
User 1  
User 5  
User 6
- Channel 3
- Channel 4

Regards  
Thomas

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [July 31, 2020, 4:00am UTC](https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196/2 "2020-07-31T04:00:22Z")

</div>

Hello, @VincentVegas

I have this SQL query that I use to extract information of the users from each team and channel including their membership.

```auto
SELECT DISTINCT u.Username, t.DisplayName AS TeamName, c.DisplayName AS ChannelName, cm.SchemeUser AS User, cm.SchemeAdmin AS Admin FROM ChannelMembers AS cm JOIN Channels AS c ON (cm.ChannelId=c.Id) JOIN Users AS u ON (cm.UserId=u.Id) JOIN Teams AS t ON (c.TeamId=t.Id);

```

Will this be something that you can consider?

---

<div class="post-metadata">

**Author:** ![VincentVegas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/vincentvegas/32/5103_2.png) [@VincentVegas](https://forum.mattermost.com/u/VincentVegas)\
**Post date:** [August 3, 2020, 10:05am UTC](https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196/3 "2020-08-03T10:05:39Z")

</div>

Thanks, that works quite well.

Regards,  
Thomas

---

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [August 3, 2020, 10:07am UTC](https://forum.mattermost.com/t/a-list-of-all-channels-with-all-users-in-them/10196/4 "2020-08-03T10:07:16Z")

</div>

Hi, @VincentVegas

You are most welcome. Always happy to help.
