<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`MEMO`, t1.`PROLEID`, t11.`SYS_ROLENAME` AS `PROLENAME`, t1.`SYS_ROLEID`, t1.`SYS_ROLENAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZROLE` t1 LEFT JOIN IBZROLE t11 ON t1.PROLEID = t11.SYS_ROLEID
WHERE T1.SYS_ROLEID NOT IN ( SELECT DISTINCT (DATA.SYS_ROLEID) FROM( SELECT @SYS_ROLEID AS _ID, ( SELECT @SYS_ROLEID := PROLEID FROM IBZROLE WHERE SYS_ROLEID = @SYS_ROLEID LIMIT 0,1 ) AS _PID, @L := @L+1 AS LEVEL FROM IBZROLE, (SELECT @SYS_ROLEID := #{srf.datacontext.sys_roleid}, @L := 0 ) B ) ID, IBZROLE DATA WHERE ID._ID = DATA.SYS_ROLEID ORDER BY LEVEL)
WHERE T1.SYS_ROLEID NOT IN ( SELECT ID.LEVEL, DATA.* FROM( SELECT @IDS AS _IDS, ( SELECT @IDS := GROUP_CONCAT(ID) FROM TABLE1 WHERE FIND_IN_SET(PARENT_ID, @IDS) ) AS CIDS, @L := @L+1 AS LEVEL FROM TABLE1, (SELECT @IDS := #{srf.datacontext.sys_roleid}, @L := 0 ) B WHERE @IDS IS NOT NULL ) ID, TABLE1 DATA WHERE FIND_IN_SET(DATA.ID, ID._IDS) ORDER BY LEVEL, ID)
AND T1.SYS_ROLEID NOT IN ( SELECT DISTINCT (DATA.SYS_ROLEID) FROM( SELECT @SYS_ROLEID AS _ID, ( SELECT @SYS_ROLEID := PROLEID FROM IBZROLE WHERE SYS_ROLEID = @SYS_ROLEID LIMIT 0,1 ) AS _PID, @L := @L+1 AS LEVEL FROM IBZROLE, (SELECT @SYS_ROLEID := #{srf.datacontext.sys_roleid}, @L := 0 ) B ) ID, IBZROLE DATA WHERE ID._ID = DATA.SYS_ROLEID ORDER BY LEVEL)