Hi I am quite new to MySQL events and triggers, I have a table called userstatus(userid, timestamp,count, flag) which is used to store data about the user if he's blocked or not. When count reaches 4, the flag becomes 0(blocked). Can you please help me on what I can do to automatically reset the flag to 1 after it remains blocked for an hour. I have tried the following code:
create event testevent
on schedule
every 1 minute
starts CURRENT_TIMESTAMP
do
update demo.userstatus set flag=1
where timestampdiff(hour,timestamp,CURRENT_TIMESTAMP)>1
This seems to work but is not efficient. Any help would be appreciated. Thanks!