Admin SQL queries

From TempusServa wiki
Revision as of 08:51, 10 January 2024 by Kpe (talk | contribs) (Created page with "=== Extract list of users and groups === One line for each group SELECT user.Name, user.EMAIL, user.IsActive, usergroup.Groupname, usergroup.LDAPNAME FROM user INNER JOIN usergroupmember ON usergroupmember.UserID = user.UserID INNER JOIN usergroup ON usergroupmember.GroupID = usergroup.GroupID ORDER BY 1 One line for each user SELECT user.Name, user.EMAIL, user.IsActive, GROUP_CONCAT(usergroup.Groupname) AS ListOfGroups FROM user INNER JOIN usergroupm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Extract list of users and groups

One line for each group

 SELECT user.Name, user.EMAIL, user.IsActive, usergroup.Groupname, usergroup.LDAPNAME
 FROM user
 INNER JOIN usergroupmember ON usergroupmember.UserID = user.UserID
 INNER JOIN usergroup ON usergroupmember.GroupID = usergroup.GroupID
 ORDER BY 1

One line for each user

 SELECT user.Name, user.EMAIL, user.IsActive, GROUP_CONCAT(usergroup.Groupname) AS ListOfGroups
 FROM user
 INNER JOIN usergroupmember ON usergroupmember.UserID = user.UserID
 INNER JOIN usergroup ON usergroupmember.GroupID = usergroup.GroupID
 GROUP BY usergroup.GroupID
 ORDER BY 1