CREATE TRIGGER `have_new_log` BEFORE UPDATE ON `st_include`
FOR EACH ROW BEGIN
IF (OLD.ads_me_have_new = 0 AND NEW.ads_me_have_new = 1) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' ads 0->1 ', NOW(), ';');
ELSEIF (OLD.ads_me_have_new = 1 AND NEW.ads_me_have_new = 0) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' ads 1->0 ', NOW(), ';');
END IF;
IF (OLD.opm_me_have_new = 0 AND NEW.opm_me_have_new = 1) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' opm 0->1 ', NOW(), ';');
ELSEIF (OLD.opm_me_have_new = 1 AND NEW.opm_me_have_new = 0) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' opm 1->0 ', NOW(), ';');
END IF;
IF (OLD.gft_me_have_new = 0 AND NEW.gft_me_have_new = 1) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' gft 0->1 ', NOW(), ';');
ELSEIF (OLD.gft_me_have_new = 1 AND NEW.gft_me_have_new = 0) THEN
SET NEW.have_new_log = CONCAT(OLD.have_new_log, ' gft 1->0 ', NOW(), ';');
END IF;
END
При данном запросе ничего не происходит:
UPDATE `st_include` SET `opm_me_have_new` = '1' WHERE `st_include`.`id` = 1;