# List of all Members of a Group with Custom Field

**URL:** https://meta.discourse.org/t/list-of-all-members-of-a-group-with-custom-field/275003
**Category:** Data & reporting
**Tags:** sql-query, user-custom-fields
**Created:** [15 בספטמבר,‏ 2016,‏ 4:11pm UTC](https://meta.discourse.org/t/list-of-all-members-of-a-group-with-custom-field/275003 "2016-09-15T16:11:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [15 בספטמבר,‏ 2016,‏ 4:11pm UTC](https://meta.discourse.org/t/list-of-all-members-of-a-group-with-custom-field/275003/1 "2016-09-15T16:11:41Z")

</div>

# List of all Members of a Group with Custom Field

We use this query to get a list of the name and matriculation number of all team members:

```sql
SELECT users.name, user_custom_fields.value as matriculation
FROM users
JOIN group_users ON users.id = group_users.user_id
JOIN groups ON groups.id = group_users.group_id
JOIN user_custom_fields ON users.id = user_custom_fields.user_id
WHERE groups.name = 'Team'
AND user_custom_fields.name = 'user_field_2'

```

Simply insert the group name and the custom field id in the last two names.
