以下這樣寫會報錯:
[Error] 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
www.2cto.com
create procedure test(in a int)
if a > 1 then
select 1;
elseif a>2 then
select 2;
else
end if;
[xhtml]
create procedure test(in a int)
if a > 1 then
select 1;
elseif a>2 then
select 2;
else
www.2cto.com
end if;
應改成以下這樣:
create procedure test(in a int)
if a > 1 then
select 1;
elseif a>2 then
select 2;
else
-- do nothing --
set @tmp=1;
end if;
作者 zhu473105308