1CREATE TRIGGER after_sales_update
2AFTER UPDATE
3ON sales FOR EACH ROW
4BEGIN
5 IF OLD.quantity <> new.quantity THEN
6 INSERT INTO SalesChanges(salesId,beforeQuantity, afterQuantity)
7 VALUES(old.id, old.quantity, new.quantity);
8 END IF;
9END$$