While this line is not necessary it’s a good idea to limit to this initially until you are ready to run on a larger scale.
AND data1 LIKE "%<Organization Name>%"
SELECT _id ,raw_contact_id ,data1 ,data4 ,data5 FROM data WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%" ) AND data1 LIKE "%<Organization Name>%" AND raw_contact_id IN ( SELECT raw_contact_id FROM data WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%" ) GROUP BY raw_contact_id HAVING count(raw_contact_id) > 1 );
DELETE FROM data WHERE _id IN ( SELECT max(_id) AS _id FROM data WHERE data1 LIKE "%<Organization Name>%" AND raw_contact_id IN ( SELECT raw_contact_id FROM data WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%" ) GROUP BY raw_contact_id HAVING count(raw_contact_id) > 1 ) );
Originally Posted on March 26, 2014
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.