mysql 删掉重复数据

时间:2021-09-23 05:41:13
--不知道为啥这个mysql外边还要包一层,不然就报错
DELETE
FROM
course
WHERE
name IN (
select mm.name from (
SELECT
a.name as name
FROM
course a
GROUP BY
a. NAME
HAVING
count(a.NAME) > 1)mm
)
AND id NOT IN (
select nn.id from (
SELECT
min(id) as id
FROM
course a
GROUP BY
a. NAME
HAVING
count(a.NAME) > 1)nn
);