Hi Community
This may be more of a SQL question then a Jira question, but here I am since someone may have encountered the same need for extracting users.
I'm trying to extract all members of the groups "jira-stage-users" and "Casino", while also excluding users from the extraction which are in the "atlassian-addons", "External" and "Consultants" groups.
Users in the groups to exclude can also be in the jira-stage-users and Casino groups, so i can't simply take all users from those two groups.
The users I'm extracting must also be active.
With my current script, I'm getting all users from all 5 groups and the ones who's members of the 5 groups that are to be excluded and not removed from the results.
The users can be members of both the jira-stage-users and Casino groups at the same time as being members of the groups that's to be excluded. Those users should not be included in the returned result.
My current script is:
SELECT DISTINCT
cwd_user.lower_user_name, cwd_user.display_name, cwd_user.lower_email_address
FROM cwd_user
JOIN cwd_membership ON cwd_membership.child_id = cwd_user.id
JOIN cwd_group on cwd_membership.parent_id = cwd_group.id
WHERE (cwd_group.group_name = 'jira-stage-users' or cwd_group.group_name = 'Casino')
AND (cwd_group.group_name != 'atlassian-addons' AND cwd_group.group_name != 'External' AND cwd_group.group_name != 'Consultants')
AND cwd_user.active = 1
We're on a PostgreSQL database.
I'm probably missing a simple method in order to make it work, if anyone has any ideas it's much appreciated.
Thanks in advance.