Original sql statement
- identify all the permissions menu the user has permission table according to the SELECT * from tb_power the WHERE in the above mentioned id ( the SELECT power_id from tb_role_power in the WHERE role_id ( the SELECT role_id from tb_user_role the WHERE userid = 1 ) )
Optimized
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 )