用户admin所属角色组的id是固定的,用一条sql列出admin所有的角色信息

admin所属角色组字段内容(id)为:1
admin角色组对应的角色字段内容(id)为:1,2,3,5,6,7,8,9,10,11,12
select 
s.*,r.* 
from
(select 
e.*,g.roles
from employee e 
inner join roleGroup g
on e.rolegroupid=g.id
where 
e.account='admin'
)s,
role r
where ','+s.roles+',' like '%,'+cast(r.id as varchar(10))+',%'

查询字段简化后的显示效果图:

猜你喜欢

转载自franciswmf.iteye.com/blog/2271356