begin
declare currentMonth int;
declare half int default 0;
set currentMonth = (select DATE_FORMAT(now(),"%m"));
if(currentMonth > 5)
**begin**
set half = 1
end
end;
This is screen shot of what error is shown
向我显示此错误:在'begin set half = 1;附近使用正确语法的MySQL服务器版本;在第6行结束时选择currentMonth成一半
最佳答案
在选择集中使用into
没用
begin
declare currentMonth int;
declare half int default 0;
select DATE_FORMAT(now(),"%m") INTO @currentMonth;
if(currentMonth > 5) THEN
set half = 1;
end if;
end
关于mysql - 为什么if语句的'begin'关键字在存储过程中显示错误。 (mysql)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39160824/