我有以下程序:

CREATE PROCEDURE incDate(fromdate date, todate date)

SET currDay = fromdate;
SET endDAY = todate;

REPEAT
  SET currDay = DATE_ADD(currDay, INTERVAL 1 DAY);
  INSERT INTO `dentists`.`dayT` (`day`) VALUES (currDay);
UNTIL currDay > endDAY END REPEAT;

END

但MySQL给了我以下错误:
#1193 - Unknown system variable 'currDay'

为什么会这样?

最佳答案

User-defined variables must be prefixed with @

SET @currDay = fromdate, @endDAY = todate;

关于mysql - MySQL date_add REPEAT循环错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17505481/

10-11 11:18