SQL语句 用户角色表table中,用户A有多个角色,,怎样查出该表中所有与用户A的角色配置相同的所有用户
1个回答
展开全部
create table testname (
juese varchar(20)
,yonghu varchar(20)
);
select t3.yonghu
from testname t3
inner join ( select yonghu
from ( select yonghu ,count(*)
from testname t1
group by yonghu
having count(*) = ( select count(*) from testname where yonghu = '1' )
)
) t2
on t3.yonghu = t2.yonghu
inner join testname t4
on t3.juese = t4.juese
and t4.yonghu = '1'
group by t3.yonghu
having count(*) = ( select count(*) from testname where yonghu = '1')
写的 看着可能稍微乱点,但是能看清思路,大概就是这个意思了
juese varchar(20)
,yonghu varchar(20)
);
select t3.yonghu
from testname t3
inner join ( select yonghu
from ( select yonghu ,count(*)
from testname t1
group by yonghu
having count(*) = ( select count(*) from testname where yonghu = '1' )
)
) t2
on t3.yonghu = t2.yonghu
inner join testname t4
on t3.juese = t4.juese
and t4.yonghu = '1'
group by t3.yonghu
having count(*) = ( select count(*) from testname where yonghu = '1')
写的 看着可能稍微乱点,但是能看清思路,大概就是这个意思了
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询