Create event at NOW() + INTERVAL (8 - DAYOFWEEK(NOW())) DAY
mysql>
mysql> CREATE TABLE EVENTS_INVOKED
-> (EVENT_NAME VARCHAR(20) NOT NULL,
-> EVENT_STARTED TIMESTAMP NOT NULL);
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> CREATE EVENT NEXT_SUNDAY
-> ON SCHEDULE AT
-> NOW() + INTERVAL (8 - DAYOFWEEK(NOW())) DAY
-> DO INSERT INTO EVENTS_INVOKED
-> VALUES ('NEXT_SUNDAY',NOW());
ERROR 1537 (HY000): Event 'NEXT_SUNDAY' already exists
mysql>
mysql> drop table EVENTS_INVOKED;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
Related examples in the same category