create trigger update_order_status after update on order_sale for each row begin declare count1 int; declare count2 int;declare status_id int ;select order_status_id from `order` where id=new.order_id into status_id; select count(id) from order_sale where order_id=new.order_id into count1; select count(id) from order_sale where order_id=new.order_id and status=18 into count2; if count1=count2 and new.status=18 and new.status<>old.status then update `order` set comment='18' where id=new.order_id; update order_status set code='18' where id=status_id; end if; end
mysql 触发器用法笔记
最新推荐文章于 2023-04-10 22:07:28 发布