These are here purely to jog my own memory as to how I did things. Probably not much use to anyone else
--2008-02-06
--added new fields: mast_contacts.firm_num, mast_contacts.no_office, mast_firm.dup_branch
--added new indexes on: mast_firm.master_id_tag, mast_firm.office_id (UNIQUE)
SELECT * FROM mast_contacts c JOIN mast_firm f ON f.office_id = c.office_id
WHERE firm_num is null ORDER BY f.office_id;
UPDATE mast_contacts c JOIN mast_firm f ON f.office_id = c.office_id
SET c.firm_num = f.mast_firm_num
WHERE dup_branch= -1 AND c.city = f.city;