I want to setup a event scheduler in mysql, I'm using mysql and php, I know mysql but I'm new to events, so what I would like to do is to schedule an event every day at 00:00:01, and the query must do an update on a table, after checking 2 tables. How do I setup a query trying to check some ids from a table to another, and after execute it as an event? Is it better if I do it another way, by using cron?
Asked
Active
Viewed 306 times
0
-
Well I wouldn't use cron unless you are already a cron expert and just want to stay in that space. I have 3 event examples off my profile page. Check out the [quick with picture](http://stackoverflow.com/a/37901661) . Date it to start back a month at the right time of day and you are off to the races. – Drew Sep 17 '16 at 17:06
-
And where do I execute my event once I write the query? In the SQL tab as a normal query? – alexcr Sep 17 '16 at 18:48
-
Events run behind the scenes on a schedule. You don't "run them" yourself – Drew Sep 17 '16 at 19:19
-
Yes I understand that, but where do I type the code, so it can start tu run behind the scenes? There must be any place where I type it and execute it.. – alexcr Sep 17 '16 at 20:10
-
in my "quick with picture" above, the first block of code is typed with the current db selected, and entered and run, inside of the likes of MySQL Workbench. If done in PHPMyAdmin you don't use `DELIMITER` blocks. Then you follow the other steps to activate the global event handler (turning it on). As for your actual code you want to run, make it as complex and as long as you want and enter it inside of the `BEGIN END` block – Drew Sep 17 '16 at 20:20