I have a MySQL database with two tables: drivers and devices
The drivers table has a field called expiration date. The devices table has a field called status.
My goal is to create an event that will:
Is such a thing possible? Like an expiration check
This is the query your event needs to execute:
As for event creation, you have several options, some of which are listed here:
Regardless, you may want to wrap your
UPDATE
in astored procedure, and if there are more writes, you may also want to call this event when Wrap atransaction.Okay, consider the following
MySQL
table structure:You need to go through each driver to see if it has expired and update the device correctly.
First, you need to enable
EVENTS
in the database:Next, you can create an
event
that runs daily, checking allactive
devices forexpired
drivers and updating them appropriately: