原sql语句
-- 根据权限表查出该用户拥有的所有权限菜单 select * from tb_power where id in( select power_id from tb_role_power where role_id in( select role_id from tb_user_role where userid=1 ) )
优化后
1 -- 优化 2 select * from tb_power p where exists( 3 select power_id from tb_role_power rp where exists( 4 select 1 from tb_user_role ur where userid=1 and ur.role_id=rp.role_id 5 ) and p.id=rp.power_id 6 )