DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`news_afterUpdate` AFTER UPDATE ON `news` FOR EACH ROW BEGIN IF !(NEW.image <=> OLD.image) THEN CALL image_unref('news', OLD.image); CALL image_ref('news', NEW.image); END IF; END$$ DELIMITER ;