PostgreSQL
 sql >> Base de données >  >> RDS >> PostgreSQL

Supprimer les doublons dans postgres

DELETE from posts del 
WHERE EXISTS (
        SELECT *
        FROM posts ex
        WHERE ex.external_id = del.external_id
        AND ex.id < del.id -- if you want to keep the lowest id
        -- AND ex.id > del.id -- if you want to keep the highest id
        );