/* change Notts City Hospital from RHALB to RX1CC: */ UPDATE `referral_sources` SET `organisation_code` = 'RX1CC', `parent_organisation_id` = 219 WHERE `display_name`= 'Nottingham City Hospital'; /* referrer.id's already allocated to RX1 (po.id = 219): */ select rd.referrer_id from referrer_department rd where rd.parent_organisation_id = 219; # RX1 /* set referrer_department.parent_organisation_id from 70 to 219 except ones that already are: */ #select * from referrer_department rd update referrer_department rd set rd.parent_organisation_id = 219 where rd.parent_organisation_id = 70 and rd.referrer_id not in ( 31145, 36049, 11016, 31444, 37713 /* already have entries for 219 */ ) /* set 1 duplicate referrer inactive: */ UPDATE `hilis4`.`referrer_department` SET `is_active` = 'no' WHERE `referrer_id` = 11016 and parent_organisation_id = 70; /* already has a 219 entry */