0
votes

I have 2 tables that I want to be synchronized when insert, update or delete can I create more than one trigger on the same table??

I already wrote code like that .. but it doesn't work .. but when I create only one trigger it works correctly.

the code is something like that:

CREATE TRIGGER photosinsert BEFORE INSERT ON photos FOR EACH ROW BEGIN INSERT INTO old_photo SET PhotoID = NEW.photo_id, photo_original = NEW.file_name ; END;

delimiter |

CREATE TRIGGER photosupdate BEFORE UPDATE ON photos FOR EACH ROW BEGIN UPDATE old_photo SET photo_original = NEW.file_name WHERE PhotoID = NEW.photo_id ; END;

delimiter |

CREATE TRIGGER photosdelete BEFORE DELETE ON photos FOR EACH ROW BEGIN DELETE FROM old_photo WHERE PhotoID = OLD.photo_id ; END;


is there a solution for that, please?

1

1 Answers

0
votes

Put all code into single trigger.
You can use multiple statements between BEGIN and END