1DELIMITER $$
2CREATE TRIGGER invlevel_AUPD
3AFTER UPDATE ON invlevel
4FOR EACH ROW
5BEGIN
6 IF NEW.quantity < 20 THEN
7 INSERT INTO orders (productid, amount)
8 SELECT productid, amount
9 FROM reorder
10 WHERE productid = NEW.productid;
11 END IF;
12END$$
13DELIMITER ;