Subject Re: [firebird-support] Duplicate record deletion
Author Arno Brinkman
Hi,

> I think a while back on this list that someone suggested using the
> dbkey to delete duplicate records. So I thought I would give it a try
>
> the subselect in the following statement returns 3008 records out of
> the total of 3068. However the full statement does nothing.
>
> delete from ppm_mappings m2
> where m2.rdb$db_key not in
> (select min(m1.rdb$db_key) from ppm_mappings m1
> group by m1.matrix_id, m1.product_id, m1.process_id)
>
> Am I barking up the wrong tree?

I don't think using the DB_KEY is a good idea. Can't you solve it another way?

Like:

DELETE FROM
ppm_mappings m2
WHERE
NOT SINGULAR(SELECT 1 FROM ppm_mappings m1 WHERE
m1.matrix_id = m2.matrix_id and
m1.product_id = m2.product_id and
m1.process_id = m2.process_id)

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info