1
I’m trying to create an automatic event in Mysql so that every 24 hours it runs the following command to delete promotions without admin interaction, where if the end date is shorter than the current date will delete, I’m not sure if it works.
CREATE EVENT excluirPromocao
ON SCHEDULE EVERY 24 HOUR
ON COMPLETION PRESERVE
DO
DELETE FROM promocao where data_termino < NOW();
//New event
CREATE EVENT
EXCLUIR_PROMOCAO
ON SCHEDULE EVERY
24 HOUR
ON COMPLETION PRESERVE
DO
DELETE FROM
promocao
WHERE
data_termino < CURDATE();
is in date format
– fabricio b.
Oops, sorry is the end date less than the current date
– fabricio b.
Two remarks, check in your my.ini the event_scheduler variable, it has to be with value 1 to work, after changing if you need to restart the Mysql service, second point is the type of data that is in your data_terminus field, if a datetime is ok, but if it’s just a date change the Where clause to: Where data_termino < DATE(NOW());
– arllondias