日期:2014-05-17 浏览次数:20564 次
select a.role_id,a.auy_id,a.auy_name,m.md_name from role_auy as ra left join auy as a on a.auy_id=ra.auy_id inner left join module as m on m.md_id=a.md_id where ra.role_id=1;
------解决方案--------------------
SELECT * FROM role_auy AS ra LEFT JOIN auy AS a ON ra.auy_id = a.auy_id LEFT JOIN module AS m ON a.md_id = m.md_id WHERE ra.role_id = '角色ID' 如果还要关联用户表 就在 WHERE前面加 LEFT JOIN sub AS s ON ra.role_id = s.role_id
------解决方案--------------------
功能放在相应的模块下面,表示模块id 是已知且固定的
又角色id已知
则连接应使用内连接或逗号连接,因为是要取得存在的功能
select* from role_auy, auy where role_auy.auy_id=auy.auy_id and role_auy.role_id=角色id and auy.md_id=模块id