mysql Event running yearly calculations

后端 未结 2 714
抹茶落季
抹茶落季 2020-12-11 23:18

I have the following code

CREATE EVENT myevent2
ON SCHEDULE EVERY \'1\' YEAR
STARTS commit_date + INTERVAL 1 YEAR
DO
UPDATE lms.loan 



        if new.app_l         


        
2条回答
  •  Happy的楠姐
    2020-12-11 23:25

    i am not sure if you can use a column value in the STARTS clause, but there is a workaround for this you can schedule this event for daily and have a extra check in all the IF clause you have, to check the date difference between commit_date and current_date() is one year.

    something like:

    if new.app_loan_type="Salary Advance Loan" and DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), commit_date)), "%Y")+0 = 1 then
    

提交回复
热议问题