Triggers
Posted on February 22, 2012
Do one action in the trigger
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH ROW
INSERT INTO test2 SET a2 = NEW.a1;
Do more actions in one trigger
delimiter |
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
|