删除重复数据
--删除peopleId, seq重复的所有数据
DELETE FROM vitae a
WHERE
(a.peopleId, a.seq) IN (
SELECT peopleId, seq FROM vitae
GROUP BY peopleId, seq
HAVING count(*) > 1
);
参考博客:https://www.cnblogs.com/jiangxiaobo/p/6589541.html
DELETE FROM user
WHERE
user_code IN (
SELECT user_code FROM
(
SELECT user_code,dept_code FROM user
WHERE
user_code IN (
SELECT user_code FROM user
GROUP BY user_code
HAVING count(user_code) > 1
)
AND dept_code NOT IN (
SELECT max(dept_code) FROM user
GROUP BY user_code
HAVING count(user_code) > 1
)
) a
)
AND dept_code IN (
SELECT dept_code FROM
(
SELECT user_code, dept_code FROM user
WHERE
user_code IN (
SELECT user_code FROM user
GROUP BY user_code
HAVING count(user_code) > 1
)
AND dept_code NOT IN (
SELECT max(dept_code) FROM user
GROUP BY user_code
HAVING count(user_code) > 1
)
) b
);