Create trigger to delete old Mysql data

Asked

Viewed 32 times

0

Good morning.

have a table "data" in this table are saved various information like 'user_id' and 'time';

I would like to create a trigger for when entering a new data delete the older than 90 days.

In the Mysql command line it looks like this:

DELETE FROM `dados` WHERE `user_id` = user_id AND `time` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 DAY));

Anyone can help?

  • What have you tried so far? What do you expect to happen if this table does not receive any information from that user in 90 days?

  • I created the trigger by phpmyadmin, and it returns an error, I am no longer access here once I have access here put the error.

  • If you don’t receive information, do nothing. In fact, this would be another trigger to be executed at another time, but if you have another idea. Will be.

  • "Can’t update table 'data' in stored Function/Trigger because it is already used by statement which Invoked this stored Function/Trigger"

  • This is the error that appears when I register the cat

No answers

Browser other questions tagged

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