in Oracle there are similar constructs, but can this also be done in mysql?
How to make a mysql update trigger fire only when a specific field changes, not the whole row
CREATE TRIGGER tab.event
BEFORE
INSERT OR UPDATE OF id, tex ON tab.emp
FOR EACH ROW
CREATE
DEFINER = 'root'@'127.0.0.1'
TRIGGER baza.logevent
AFTER UPDATE
ON baza.user
FOR EACH ROW
BEGIN
IF (@DISABLE_TRIGGERS IS NULL) and (OLD.status <> NEW.status) THEN
INSERT INTO feed Set feed.id_event = NEW.id , feed.userId = NEW.Id;
INSERT INTO changestatus Set changestatus.id_user = NEW.id , changestatus.text_status = OLD.status;
END IF;
END
as an option, you can check whether the field has changed or not (OLD.status <> NEW.status)
Also, don't forget what values can occur for which event type (INSERT UPDATE DELETE before-after)

Comments