Author: Joyce Zhou
In a production environment, User membership can get complicated due to nested User Groups.
The following query gives an overview of the mapping of all Users and User Groups.
FROM fnGetAllUsersAffiliations() F
INNER JOIN Users U
ON F.UserID = U.UserID
INNER JOIN Users R
ON F.ParentID = R.UserID
WHERE F.UserID <> F.ParentID
Here is a sample result. Please note, this result has unfolded all of the nested User Group relationships.