SELECT *FROM sys_role_permission mainWHERE (SELECT COUNT(1) FROM sys_role_permission sub WHERE main.sys_role_id = sub.sys_role_id AND main.sys_permission_id > sub.sys_permission_id ) < 3;