时间:2021-07-01 10:21:17 帮助过:7人阅读
#创建触发器test4 CREATE TRIGGER test4 AFTER INSERT ON `ord` FOR EACH ROW BEGIN UPDATE goods SET num= num - new.much WHERE goods_id = new.gid; END$$
当然我这仅仅是简单的固定了一个值,事实上能够用语句获取到动态的库存值。
#创建触发器test5 CREATE TRIGGER test5 BEFORE INSERT ON `ord` FOR EACH ROW BEGIN IF new.much >26 THEN SET new.much = 26; END IF; UPDATE goods SET num= num - new.much WHERE goods_id = new.gid; END$$
MySQL触发器 trigger之after与before区分
标签:pre test creat 动态 blog iss 库存 最大数 enter