From e491a4dce73954486a03c68301a37bdbe78ecb8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Mar 2014 20:29:01 +0100 Subject: [PATCH] Add code to clean duplicate records --- htdocs/install/mysql/migration/repair.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 099d4f7598d..3cd1f430f9b 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -102,3 +102,17 @@ update llx_opensurvey_sondage set format = 'A' where format = 'A+'; -- ALTER TABLE llx_facture_fourn ALTER COLUMN fk_cond_reglement DROP NOT NULL; + +-- Sequence to removed duplicated values of barcode. Use serveral times if you still have duplicate. +create table tmp_product as (select * from llx_product); +select barcode, max(rowid) from tmp_product where barcode is not null group by barcode having count(rowid) >= 2; +update llx_product set barcode = null where barcode is not null and (barcode, rowid) in (select barcode, max(rowid) from tmp_product where barcode is not null group by barcode having count(rowid) >= 2); +drop table tmp_product; + +-- Sequence to removed duplicated values of barcode. Use serveral times if you still have duplicate. +create table tmp_societe as (select * from llx_societe); +select barcode, max(rowid) from tmp_societe where barcode is not null group by barcode having count(rowid) >= 2; +update llx_societe set barcode = null where barcode is not null and (barcode, rowid) in (select barcode, max(rowid) from tmp_societe where barcode is not null group by barcode having count(rowid) >= 2); +drop table tmp_societe; + +