ERROR 1064 (42000): 你的 SQL 语法有误;在第 15 行的 '' 附近

ERROR 1064 (42000):You have an error in your SQL syntax; near '' at line 15

我只想在 mysql 5.7 中创建简单的函数,但出现以下错误....

尝试了所有可能的方法....但没有运气....请找出错误。

Table : select * 来自 emp_tab;
+--------+--------+-----+--------+ | empno |命名 |盐 |部门编号 |

+--------+--------+------+--------+ | 7101 |马丁 | 4000 | 10 |

函数语法:

mysql> 创建函数 employeebonus(eno int(10))

-> returns double deterministic
-> begin
-> declare temp double;
-> declare bonus double;
-> select sal into temp from emp_tab where empno=eno;
-> if temp<=10000 then
-> set bonus=temp*0.10;
-> else if temp<=20000 then
-> set bonus=temp*0.20;
-> else
-> set bonus=temp*0.30;
-> end if;
-> return bonus;
-> end$$   

在第 15 行,尝试了另一种语法 ->结束; ->$$ 和 ->结束 ->$$

但没有任何效果

ERROR 1064 (42000):你的SQL语法有误;查看与您的 MySQL 服务器版本相对应的手册,了解在第 15 行

附近使用的正确语法

这一行有错误...

else if temp<=20000 then

此行应更正为

elseif temp<=20000 then

“else if”之间没有 space ...它的“elseif”