要求能够通过一个sql语句删除所有重复的记录,并只留下重复记录中的一条数据
思路:
1 --- 删除重复的角色权限配置 2 DELETE FROM sys_roleright_t t4 WHERE t4.FRIGHTID IN ( 3 SELECT t1.FRIGHTID 4 FROM sys_roleright_t t1 5 JOIN (SELECT min(t2.FRIGHTID) AS FRIGHTID, t2.FROLEID, t2.FAPPID, count(0) 6 FROM sys_roleright_t t2 7 GROUP BY t2.FROLEID, t2.FAPPID 8 HAVING count(0) > 1 9 ) t3 ON t1.FROLEID = t3.FROLEID AND t1.FAPPID = t3.FAPPID 10 WHERE t1.FRIGHTID > t3.FRIGHTID 11 );