2021-11-10

数据库按照多字段去重

sql如下:

DELETE
FROM
student
WHERE
id IN (
select m.id from

(SELECT
    id
FROM
    student A,
    ( SELECT StuName,ClassName,address FROM student GROUP BY StuName,ClassName,address HAVING COUNT(*) > 1 ) B
WHERE
    A.StuName  = B.StuName 
    AND A.ClassName  = B.ClassName
  and A.address=B.address
AND A.id NOT IN ( SELECT MIN( id ) AS ID FROM student GROUP BY StuName,ClassName,address HAVING COUNT(*) > 1 )) m
)
上一篇:className用法


下一篇:大数据教程系列之大数据概念