SQL SERVER-写sql可以依据最终要的结果由近及远或者依据已有的条件由近及远来写

//调休数据库 

select distinct(m.Name) from tbUser u
 join tbUserRole ur on u.Id=ur.UserId
 join tbRole r on ur.RoleId= r.id
 join tbRoleMenuButton rmb on r.Id = rmb.RoleId
 join tbMenu m on rmb.MenuId=m.Id
 where u.Id=1209

 select distinct(m.Name) from tbMenu m
 join tbRoleMenuButton rmb on m.Id=rmb.MenuId
 join tbRole r on rmb.RoleId = r.Id
 join tbUserRole ur on r.Id = ur.RoleId
 join tbUser u on ur.UserId = u.Id
 where u.Id=1209

展开阅读全文

没有更多推荐了,返回首页