Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Mehrere Insert/Update-Anweisungen innerhalb des Triggers?

Aus den Dokumenten:Trigger-Syntax erstellen

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;