Reputation: 13
I want to give my users bonus every day at 00:01 AM, so i am looking for an automatic trigger in mysql to update Bonus in users.
UPDATE users SET bonus = bonus + 10
How can i do this ?
Thank you
Upvotes: 0
Views: 4184
Reputation: 222672
MySQL has a built-in scheduler that can be used to execute tasks according to a given schedule.
Here is how to create a scheduled event for your use case:
create event grant_user_bonus_daily
on schedule every 1 day
starts current_date + interval 1 day + interval 1 minute -- starts tomorrow at 00:01
do
update users set bonus = bonus + 10;
Upvotes: 1