DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate` AFTER UPDATE ON `client` FOR EACH ROW BEGIN IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; UPDATE `address` SET isDefaultAddress = TRUE WHERE id = NEW.defaultAddressFk; END IF; IF NOT NEW.isActive THEN UPDATE account.`user` SET active = FALSE WHERE id = NEW.id; END IF; END$$ DELIMITER ;