mysql 方法那里错了? 一直觉得没问题

delimiter $
create function iff(id int,num int) returns varchar(20) deterministic
begin
declare str varchar(20);
if id else if id>num then SET str=concat(id,'大于',num);
else set str=concat(id,'等于',num);
end if;
return str;
end $
delimiter ;

http://www.jb51.net/article/27825.htm

MySQL中if语句的形式应该如下:

 IF condition1 THEN
   {...statements to execute when condition1 is TRUE...}

[ ELSEIF condition2 THEN
   {...statements to execute when condition2 is TRUE...} ]

[ ELSE
   {...statements to execute when both condition1 and condition2 are FALSE...} ]

END IF;

题目中是:

 if id else if id>num then SET str=concat(id,'大于',num);

第一个if后面少了then

不是的 报的错失不是在那

报的错在 end $ 这里