new 的使用 mysql> create trigger alter_goods_number after insert on `order` for each row up date goods set goods_number=goods_number-new.buy_number where goods_id=new.goods _id;
mysql> insert into `order` values(4,'samsung',5);
old 的使用
mysql> create trigger back_goods_number after delete on `order` for each row upd ate goods set goods_number=goods_number+old.buy_number where goods_id=old.goods_ id;
mysql> delete from `order` where goods_id=1;
更新 (update将之前下的订单撤销,再重新下订单)
mysql> create trigger update_goods_number after update on `order` for each row u pdate goods set goods_number=goods_number+old.buy_number-new.buy_number where go ods_id=new.goods_id;