Creating a temporary table consisting of unique Addresses
CALL duporderremoval('kloustalot@valerus-co.com');
#In excel
=CONCATENATE("CALL duporderremoval('",A339,"');")
/*----DELETING DUPLICATE ENTRIES----*/
/*Creaing a temporary table consisting of unique Addresses*/
CREATE TEMPORARY TABLE IF NOT EXISTS max_customer_address_entity AS (SELECT t0.parent_id,t0.entity_id,t0.city FROM customer_address_entity AS t0 left JOIN customer_address_entity AS t1 ON t0.parent_id=t1.parent_id AND t0.city=t1.city AND t0.street=t1.street AND t0.firstname=t1.firstname AND t0.lastname=t1.lastname AND t1.entity_id>t0.entity_id where t1.entity_id IS NULL);
/*Indexing for fast processing*/
CREATE INDEX `i1` on max_customer_address_entity (`entity_id`);
/*Deleting values from customer_address_entity table whose entity_id is not present in temporary table */
delete s from customer_address_entity s join (select t1.entity_id from customer_address_entity t1 left outer join max_customer_address_entity t2 on t1.entity_id = t2.entity_id where t2.entity_id is null) as z on s.entity_id = z.entity_id;