tuhaishi
tuhaishi

Reputation: 3

How to create a trigger on table to update field after one hour if a specific value have been set

My database stores the parking status information 1 The status field has three values (0 for empty, 1 for occupied and 2 for waiting) If the parking status remains 2 for 1 hour I want to set it to 0 and set the username field to null.

Is there any way to do it with triggers.

Upvotes: 0

Views: 827

Answers (1)

Rahul
Rahul

Reputation: 77876

You probably looking to create a Event like

CREATE EVENT myevent
ON SCHEDULE EVERY HOUR 
DO
UPDATE mytable 
SET status = 0, username = null
where status = 2;

Upvotes: 3

Related Questions