select id from sales_promotion where endtime< now() and status!=0//
delete sales_promotion from sales_promotion,bulk_order where sales_promotion.id=bulk_order.group_id and bulk_order.endtime< now() and status=0//
DELIMITER //
create procedure autodel()
begin
delete from sales_promotion where endtime<now() and status=0;
end//
DELIMITER ;
create event event_auto_del_sales_promotion
on schedule every 1 day starts ‘2019-4-22 15:00:00’
on completion not preserve enable do call autodel();
事件开启与关闭:
ALTER EVENT event_auto_del_sales_promotion ON COMPLETION PRESERVE ENABLE; //开启某事件
ALTER EVENT event_auto_del_sales_promotion ON COMPLETION PRESERVE DISABLE; //关闭某事件