FAQ: I want to get a list of users who belong to a Pleasanter group
## Answer
Please use the following method to obtain the information..
1. Use the "[Group Retrieval API](/en/manual/api-group-get)"
1. Use the script "[$p.apiGroupsGet](/ja/manual/script-api-groups-get)"
1. Use the server scripts "[groups.Get](/ja/manual/server-script-groups)" and "group.GroupMembers"
1. Use SQL. Explained on this page.
---
## Overview
This is a sample SQL statement to obtain a list of "[User](/en/manual/table-management-choices-text-users)" belonging to a "[Group](/en/manual/table-management-choices-text-groups)" in Pleasanter.
## Procedure
Use SQL Server Management Studio or Azure Data Studio to connect to the Pleasanter database and execute the following SQL. The following SQL is compatible with both SQL Server and PostgreSQL.
## Sample Code
```sql
select
"Groups"."GroupId"
,"Groups"."GroupName"
,"Users"."UserId"
,"Users"."LoginId"
,"Users"."Name"
from "Groups" inner join "GroupMembers" on "Groups"."GroupId" = "GroupMembers"."GroupId"
inner join "Users" on "GroupMembers"."UserId" = "Users"."UserId"
-- If you delete a group under the union, users via the department will not be retrieved.
union
select
"Groups"."GroupId"
,"Groups"."GroupName"
,"Users"."UserId"
,"Users"."LoginId"
,"Users"."Name"
from "Groups" inner join "GroupMembers" on "Groups"."GroupId" = "GroupMembers"."GroupId"
inner join "Depts" on "GroupMembers"."DeptId" = "Depts"."DeptId"
inner join "Users" on "Depts"."DeptId" = "Users"."DeptId"
```
## Image of Execution Result
![image](https://pleasanter.org/binaries/58db164d23bc462c8e352dcb64730e51)
## Related Information
<div id="ManualList"><ul><li><a href="/en/manual/table-management-choices-text-groups">Table Management: Editor: Item Detail Settings: Option List: Group</a><span>08.13.2024 up</span></li>
<li><a href="/en/manual/table-management-choices-text-users">Table Management: Editor: Item Detail Settings: Option List: User</a><span>08.13.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/group">Group Management Function</a><span>10.08.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/api-group-get">Developer Function: API: Group Operation: Get Group</a><span>10.01.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/script-api-groups-get">Developer Function: Script: $p.apiGroupsGet</a><span>10.04.2024 up</span></li></ul></article>
<ul><li><a href="/en/manual/server-script-groups">Developer Function: Server Script: groups</a><span>08.14.2024 up</span></li></ul></article></div><input id="SearchTextHidden" type="hidden" value="" />