每天为特定时间段创建 MySql 事件安排时出错,间隔为 i 小时

Error while creating MySql event scheduling for a specific period of time everyday with an interval of i hour

在每天特定时间段创建 MySql 事件安排时出错,间隔为 1 小时。

我的代码是

CREATE EVENT your_event ON SCHEDULE 
   EVERY 30 MINUTE
   STARTS '2013-10-01 10:00:00'
DO
  IF time(CURRENT_TIMESTAMP) between time('10:00:00') and time('18:00:00')
  then
        INSERT INTO andrew (name) values ('test')
  end if



错误是:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'end if' at line 8

试试这个;)

DELIMITER $$ 

CREATE EVENT your_event ON SCHEDULE 
   EVERY 30 MINUTE
   STARTS '2013-10-01 10:00:00'
DO
IF time(CURRENT_TIMESTAMP) BETWEEN time('10:00:00') AND time('18:00:00') THEN
    INSERT INTO andrew (name) VALUES ('test');
END IF $$

DELIMITER ;