I have to make two triggers, one that, after inserting into test1, insert into test2. So far so good, the problem I have is that I should do the same in the inverse case. When there is an insert in test2, I must do the same insert in test1. I understand that the error I have is that I can enter an infinite loop, but I would like to know if there is any possibility of solving this:
DELIMITER $$ CREATE TRIGGER 'ai_test1_test2' AFTER INSERT ON 'test1'
FOR EACH ROW
BEGIN INSERT INTO test2 (vtest2) VALUES (new.vtest1)
END$$
DELIMITER ;
In the bidirectional insert it would be:
DELIMITER $$ CREATE TRIGGER 'ai_test2_test1' AFTER INSERT ON 'test2'
FOR EACH ROW
BEGIN INSERT INTO test1 (vtest1) VALUES (new.vtest2)
END$$
DELIMITER ;
Does anyone know how I could solve it? Thanks in advance.