delete from jc_sys_data_perm WHERE data_type=3 and org_id is not null and id not in ( SELECT min(id) FROM ( select id,org_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=3 and org_id is not null ORDER BY id asc) as ns GROUP BY org_id,site_id,data_type,data_id,operation ); delete from jc_sys_data_perm WHERE data_type=3 and role_id is not null and id not in ( SELECT min(id) FROM ( select id,role_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=3 and role_id is not null ORDER BY id asc) as ns GROUP BY role_id,site_id,data_type,data_id,operation ); delete from jc_sys_data_perm WHERE data_type=3 and user_id is not null and id not in ( SELECT min(id) FROM ( select id,user_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=3 and user_id is not null ORDER BY id asc) as ns GROUP BY user_id,site_id,data_type,data_id,operation ); delete from jc_sys_data_perm WHERE data_type=2 and org_id is not null and id not in ( SELECT min(id) FROM ( select id,org_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=2 and org_id is not null ORDER BY id asc) as ns GROUP BY org_id,site_id,data_type,data_id,operation ); delete from jc_sys_data_perm WHERE data_type=2 and role_id is not null and id not in ( SELECT min(id) FROM ( select id,role_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=2 and role_id is not null ORDER BY id asc) as ns GROUP BY role_id,site_id,data_type,data_id,operation ); delete from jc_sys_data_perm WHERE data_type=2 and user_id is not null and id not in ( SELECT min(id) FROM ( select id,user_id,site_id,data_type,data_id,operation from jc_sys_data_perm dataperms0_ WHERE data_type=2 and user_id is not null ORDER BY id asc) as ns GROUP BY user_id,site_id,data_type,data_id,operation