select ModuleID, ModuleName from Module where ModuleID in (select distinct ModuleID from RolePurview where RoleID in(select RolesID from User_Role where UserID in (select UserID from Users where UserName='aaa')))
select * from Functions where ModuleID=1