mercredi 10 juillet 2019

mySql query error when I try to use and IF statement

I'm not able to find the error in MySQL query

"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 '' at line 10 "

When I remove:

IF DAYOFWEEK(curdate()) BETWEEN 2 AND 6 THEN END IF;

Then the query executes fine...

I've tried using tab/space inside my IF statement

CREATE EVENT UPLOADTASK
ON SCHEDULE EVERY '1' DAY
STARTS '2019-07-09 00:00:00'
DO
IF DAYOFWEEK(curdate()) BETWEEN 2 AND 6 THEN
  INSERT INTO TABLE1 VALUES
  (1,"TASK1",curdate()-1,NULL),
  (6.5,"TASK2",curdate()-1,NULL),
  (3.0,"TASK3",curdate()-1,NULL),
  (8,"TASK44",curdate()-1,NULL);
END IF;

Aucun commentaire:

Enregistrer un commentaire