delimiter //
create procedure aa()
begin
declare x varchar(20);
set x='hjl';
if length(x)=3 then
select x;
endif;
end
//为什么老报错??
create procedure aa()
begin
declare x varchar(20);
set x='hjl';
if length(x)=3 then
select x;
endif;
end
//为什么老报错??
你什么意思?
-> begin
-> declare x varchar(20);
-> set x='a';
-> if length(x)=3 then
-> select x;
-> end if;
-> end
-> //
Query OK, 0 rows affected (0.00 sec)
-> begin
-> declare x varchar(20);
-> set x='hjl';
-> if length(x)=3 then
-> select x;
-> endif;
-> end
-> //
ERROR 1064 (42000): 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' at line 7
mysql>错误提示很清楚了,你的第七行endif;。有问题,然后你就可以看一下MYSQL手册中的语法,就立即明白 end if