飞网论坛
标题:
199、 一个用户具有多个角色,请查询出该表中具有该用户的所有角色的其他用户。
[打印本页]
作者:
johnny
时间:
2016-9-9 18:11
标题:
199、 一个用户具有多个角色,请查询出该表中具有该用户的所有角色的其他用户。
199、 一个用户具有多个角色,请查询出该表中具有该用户的所有角色的其他用户。
select count(*) as num,tb.id
from
tb,
(select role from tb where id=xxx) as t1
where
tb.role = t1.role and tb.id != t1.id
group by tb.id
having
num = select count(role) from tb where id=xxx;
欢迎光临 飞网论坛 (https://bbs.cfei.net/)
Powered by Discuz! X3.2