报: 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 line 6DELIMITER $$ create procedure AA(a int) begin set @f=1; if (@f=1) then select 'yes'; else select 'no'; end;
mysql> create procedure AA(a int) -> begin -> set @f=1; -> if (@f=1) then select 'yes'; -> else select 'no'; -> end if; -> end;$$ Query OK, 0 rows affected (0.11 sec)mysql> call AA (0); -> $$ +-----+ | yes | +-----+ | yes | +-----+ 1 row in set (0.00 sec)Query OK, 0 rows affected (0.00 sec)少了end if;
注意楼上iihero的回复,注意那个END IF
DELIMITER $$ create procedure AA(a int) begin set @f=1; if (@f=1) then select 'yes'; else select 'no'; end if; end; $$ DELIMITER ;
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 line 6DELIMITER $$
create procedure AA(a int)
begin
set @f=1;
if (@f=1) then select 'yes';
else select 'no';
end;
-> begin
-> set @f=1;
-> if (@f=1) then select 'yes';
-> else select 'no';
-> end if;
-> end;$$
Query OK, 0 rows affected (0.11 sec)mysql> call AA (0);
-> $$
+-----+
| yes |
+-----+
| yes |
+-----+
1 row in set (0.00 sec)Query OK, 0 rows affected (0.00 sec)少了end if;
create procedure AA(a int)
begin
set @f=1;
if (@f=1) then select 'yes';
else select 'no';
end if;
end; $$
DELIMITER ;