版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/weixin_43014205/article/details/86085423
两个表 user和role 中间表是user_role
查询用户和角色的对应关系
select res.user_name,r.role_name from(select u.user_name,ur.role_id from user as u INNER JOIN user_role as ur where u.user_id=ur.user_id) as res
INNER JOIN role as r where res.role_id=r.role_id;