如何获取分配到组的用户
Posted
技术标签:
【中文标题】如何获取分配到组的用户【英文标题】:How to get users who assigned to group 【发布时间】:2021-01-07 16:34:50 【问题描述】:在我的应用程序中,会员有权管理每个任务。给予会员许可的方式是, 每个成员被分配到单独的组,每个组都有单独的权限。所以每个组的成员都会收到该组的权限。
我有以下表格结构,
组
+---------+------+
| GroupID | Name |
+---------+------+
| G1 | YYY |
+---------+------+
| G2 | XXX |
+---------+------+
| G3 | UUU |
+---------+------+
授权
+-----------------+-------------------+
| AuthorizationID | AuthorizationName |
+-----------------+-------------------+
| AUTH1 | Delete |
+-----------------+-------------------+
| AUTH2 | Send |
+-----------------+-------------------+
| AUTH3 | ADD |
+-----------------+-------------------+
会员
+----------+------+
| MemberID | Name |
+----------+------+
| 1 | PAUL |
+----------+------+
| 2 | JHON |
+----------+------+
| 3 | AMBE |
+----------+------+
| 4 | NISH |
+----------+------+
组授权
+----------------------+-----------+-------------------+
| GroupAuthorizationID | FKGroupID | FkAuthorizationID |
+----------------------+-----------+-------------------+
| 1 | G1 | AUTH1 |
+----------------------+-----------+-------------------+
| 2 | G2 | AUTH1 |
+----------------------+-----------+-------------------+
| 3 | G1 | AUTH2 |
+----------------------+-----------+-------------------+
| 4 | G3 | AUTH1 |
+----------------------+-----------+-------------------+
会员组
+---------------+-----------+------------+
| MemberGroupID | FKGroupID | FKMemberID |
+---------------+-----------+------------+
| 1 | G1 | 1 |
+---------------+-----------+------------+
| 2 | G2 | 1 |
+---------------+-----------+------------+
| 3 | G4 | 2 |
+---------------+-----------+------------+
| 4 | G4 | 3 |
+---------------+-----------+------------+
我需要获取所有具有发送授权的用户。我怎样才能给它写一个连接查询。
【问题讨论】:
【参考方案1】:Select M.name, A.Authorization
FROM Authorization A INNER JOIN GroupAuthorization GA
ON A.AuthorizationID = GA.FkAuthorizationID
INNER JOIN MemberGroup MG
ON MG.FKGroupID = GA.FKGroupID
INNER JOIN Memeber M ON M.MemberID = MG.FKMemberID
where A.AuthorizationName = 'Send'
【讨论】:
以上是关于如何获取分配到组的用户的主要内容,如果未能解决你的问题,请参考以下文章