数据库按照多字段去重
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
)