Rechercher les doublons dans une table

par Samuel Kauffmann et publié le 11/10/2012

Nous avons régulièrement besoin de vérifier ou d’identifier les doublons présent dans une table. En SQL plusieurs possibilités s’offrent à nous pour résoudre ce problème :

select i.id_project, i.name_project, i.id_origin, count(*)
from chronos_prom_link i
group by i.id_project, i.name_project, i.id_origin
HAVING count(*) > 1
ORDER BY count(*) DESC
ou sans utiliser le mot clé HAVING :
select * from chronos_prom_link t
where exists (
    select 1 from chronos_prom_link t2
    where t.id_prgmoe=t2.id_prgmoe and t.id_pjtmoe=t2.id_pjtmoe and t.rowid
Astuce    SQL   

Vous avez aimé cet article ? Découvrez d'autres sujet qui pourraient vous intéresser :