1. 程式人生 > >刪除表中的重復記錄

刪除表中的重復記錄

span not eight nbsp name font delete pan people

DELETE
FROM
    people
WHERE
    peopleName IN (
        SELECT
            peopleName
        FROM
            people
        GROUP BY
            peopleName
        HAVING
            count(peopleName) > 1
    )
AND peopleId NOT IN (
    SELECT
        min(peopleId)
    FROM
        people
    
GROUP BY peopleName HAVING count(peopleName) > 1 )

刪除表中的重復記錄