Subject | deleting duplicate records |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2009-05-26T17:25:43Z |
[FB2.1]
Hello! I want to delete *ALL* the duplicate records in a table. I mean I don't
want to leave just one version of the record, but detele all the instances. To
view my duplicate records I'm doing this:
SELECT TAREAS.propietario, TAREAS.calle_nombre, TAREAS.calle_numero FROM TAREAS
WHERE
EXISTS (SELECT 1 FROM TAREAS TT WHERE
TAREAS.id <> TT.id AND
TAREAS.fecha is not distinct from TT.fecha AND
TAREAS.propietario is not distinct from TT.propietario AND
TAREAS.calle_nombre is not distinct from TT.calle_nombre AND
TAREAS.calle_numero is not distinct from TT.calle_numero)
ORDER BY TAREAS.propietario
But I can figure out how to delete. This doesn't delete all the recods. One is
left...
DELETE FROM TAREAS
WHERE
EXISTS (SELECT 1 FROM TAREAS TT WHERE
TAREAS.id <> TT.id AND
TAREAS.fecha is not distinct from TT.fecha AND
TAREAS.propietario is not distinct from TT.propietario AND
TAREAS.calle_nombre is not distinct from TT.calle_nombre AND
TAREAS.calle_numero is not distinct from TT.calle_numero)
I don't undestand why... Any help?
Thanks!
-s
Hello! I want to delete *ALL* the duplicate records in a table. I mean I don't
want to leave just one version of the record, but detele all the instances. To
view my duplicate records I'm doing this:
SELECT TAREAS.propietario, TAREAS.calle_nombre, TAREAS.calle_numero FROM TAREAS
WHERE
EXISTS (SELECT 1 FROM TAREAS TT WHERE
TAREAS.id <> TT.id AND
TAREAS.fecha is not distinct from TT.fecha AND
TAREAS.propietario is not distinct from TT.propietario AND
TAREAS.calle_nombre is not distinct from TT.calle_nombre AND
TAREAS.calle_numero is not distinct from TT.calle_numero)
ORDER BY TAREAS.propietario
But I can figure out how to delete. This doesn't delete all the recods. One is
left...
DELETE FROM TAREAS
WHERE
EXISTS (SELECT 1 FROM TAREAS TT WHERE
TAREAS.id <> TT.id AND
TAREAS.fecha is not distinct from TT.fecha AND
TAREAS.propietario is not distinct from TT.propietario AND
TAREAS.calle_nombre is not distinct from TT.calle_nombre AND
TAREAS.calle_numero is not distinct from TT.calle_numero)
I don't undestand why... Any help?
Thanks!
-s