操作管理员

 select h.*,r.* from `hr` `h`
 left join `hr_role` `h_r` on `h`.`id` = `h_r`.`hrid`
 left join `role` `r` on `h_r`.`rid` = `r`.`id`
 where h.`id` not in(select h_r.`hrid` from hr_role h_r,role r where h_r.`rid`=r.`id` and r.`nameZh`='系统管理员')

 解释如下:将user表和role表通过left join on 进行关联

然后id不等于角色为“超级管理员的”

select h_r.`hrid` from hr_role h_r,role r where h_r.`rid`=r.`id` and r.`nameZh`='系统管理员'

这一段是逆向查找方法

猜你喜欢

转载自www.cnblogs.com/gfbzs/p/12554850.html