MySQL trigger: update when a certain time is reached

I want to create a MySQL trigger that updates a table every time one of the datetime rows in another table reaches a time date lower than now.

How to do it? Is it possible?

To illustrate:

table_1 table_2 -------- ------------------- -------- - id 1 id 1 datetime 2011-05-10 11:11:11 counter 1 

So, when time passes, and NOW() becomes 2011-05-10 11:11:12 , I want the counter to increase by 1.

+2
source share
2 answers

You can do this using a trigger and an event scheduler:
- create a trigger in the table that runs every time you update / insert
- this trigger creates a scheduled event that occurs in the datetime row and updates the second table

+3
source

You can use MySQL Event Scheduler .

+3
source

Source: https://habr.com/ru/post/1403098/


All Articles