求助 SQl 三张表查找多个列值 用户ID对应多个角色ID,每个角色ID又对应多个权限ID ,怎么选出所有权限列值
RT 即是一个用户ID对应的所有权限ID
user表 role表 privilege
--------------------- ------------------ ------------------
userID roleid pid
username rolename name
userpwd userid roleid
---------------- ------------------- -------------------
------解决方案--------------------select pid, name from privilege where roleid in
(
select roleid from role where userid in
(
select userid from user where username = 'somebody'
)
)
------解决方案--------------------select pid, name from privilege where roleid in
(
select roleid from role where userid =
(
select userid from user where username = 'somebody'
)
)