Mysql event to delete lines with expired date

Asked

Viewed 118 times

0

I’m trying to create an event to delete lines, that column date is expired, or is less than the current date.

I was trying with the following command:

create event e on schedule every 1 day do delete from Reserve where date < curdate();

But then I was testing it by adding a line with an old date and changing the every 1 day for every 1 second But I didn’t succeed...

Could someone help me with the correct query for my problem?

  • Try Where trunc(date) < kurdate(). Or, see if the format of your field date is equal to the output of kurdate.

  • If you try some other event or a different parameter for Where, it executes?

  • I couldn’t, @Diego. And yes, the format used is the same.

  • @Leonardocoelho I tried with other parameters, but I did not succeed either...

  • it is good to use Cronjob for things like these.

1 answer

5


  • 1

    I didn’t know I had to activate something before :(. But it all worked out right here, Raphael. Thank you so much!

  • No problems, good luck on your project, any doubts I’m here to help, and if you want to grant the reward I’m happy :D, but still, good luck.

  • 1

    Yes, I will. But I can’t do it for another 23 hours. :))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.