大家帮我看下 我的存储过程哪儿错了
CREATE PROCEDURE v_competition_getlabels(f1 varchar(20))
begin
if(f1='voc_id') then
select distinct voc_id,rps_voc from viw_competition_ana;
else if(f1='cop_id') then
select distinct cop_id,cop_name from viw_competition_ana;
end if;
end if;
end;
Error Code : 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 '' at line4我在front下能执行啊,怎么在PHPMYADMIN和SQLYOG下都报这个错呢,谢谢
CREATE PROCEDURE v_competition_getlabels(f1 varchar(20))
begin
if(f1='voc_id') then
select distinct voc_id,rps_voc from viw_competition_ana;
else if(f1='cop_id') then
select distinct cop_id,cop_name from viw_competition_ana;
end if;
end if;
end;
Error Code : 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 '' at line4我在front下能执行啊,怎么在PHPMYADMIN和SQLYOG下都报这个错呢,谢谢
IF search_condition THEN statement_list
[ELSEIF search_condition THEN statement_list] ...
[ELSE statement_list]
END IF
MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
mysql> delimiter //
mysql> CREATE PROCEDURE v_competition_getlabels(f1 varchar(20))
-> begin
-> if(f1='voc_id') then
-> select distinct voc_id,rps_voc from viw_competition_ana;
-> else if(f1='cop_id') then
-> select distinct cop_id,cop_name from viw_competition_ana;
-> end if;
-> end if;
-> end;
-> //
Query OK, 0 rows affected (0.00 sec)mysql> delimiter ;
mysql>