Demand:
The message in T_app_message (the message that will be sent) needs to be sent to each student once, and the message is sent to the sent state after the send is complete.
A word does not fit the code
1 /*To Delete a stored procedure*/2 Drop procedure if existsproc_sendallmsg;3 /*create a stored procedure*/ 4 CREATE PROCEDUREproc_sendallmsg ()5 BEGIN6 /*Insert First*/7 INSERTt_base_message (Sid,mid)8 SELECTA.id,b.id fromT_base_student a9 INNER JOINT_app_message bTen wherea.school_id= 1 andB.sendtime<=Now () andB.sendstatus= 0; One UPDATET_app_messageSETSendstatus= 1 whereSendtime<=Now (); A UPDATET_app_messageSETShowstatus= 1 whereEndtime<=Now (); - End - the /*Specify the database*/ - UseXSCP; - /*Delete an existing scheduled task*/ - DropEventif existsevent_sendallmsg; + - CREATEEVENT event_sendallmsg onSCHEDULE every -Second starts'2017-12-11 00:00:00' + Do ACall proc_sendallmsg; /* Call the stored procedure */
MySQL timed tasks for stored procedures and scheduled tasks