select t.* from U_RIGHT_INFO t left join U_ROLE_RIGHT_INFO m on t.ID = m.RIGHT_ID where t.MODULE='%1' and m.ROLE_ID in ( select t.ROLE_ID from U_USER_ROLE_INFO t left join U_USER_INFO m on t.USER_ID=m.ID where m.ID='%2' union select t.ROLE_ID from U_GROUP_ROLE_INFO t left join U_GROUP_INFO m on t.GROUP_ID=m.ID where m.ID in (Select t.GROUP_ID from U_USER_GROUP_INFO t left join U_USER_INFO m on t.USER_ID=m.ID where m.ID='%2' ) )