一个用户具有多个角色,请查询出该表中具有该用户的所有角色的其他用户。(跟第42条SQL语句同)

SQL数据库浏览:724收藏:1
答案:
select distinct user_id
from user_role scx
where
not exists
(
select *
from user_role scy
where
scy.user_id = '张三'
and not exits
(
select *
from user_role scz
where
scz.user_id = scx.user_id
and scz.role_id = scy.role_id