mysql error code:1064 求高手指点一下 CREATE PROCEDURE `mydb`.`new_procedure` ()
BEGIN
declare f_tablename varchar(100);
declare b int default 0;
declare cur_2 cursor for select DATATABLENAME from db_dataset;
declare continue handler for not found set b=1;
open cur_2;
fetch cur_2 into f_tablename;
set @a=f_tablename;
set @stmt0:=concat("set @p=1 if exists ",@a);
prepare stmt0 from @stmt0;
execute stmt0;
while (b<>1 and @p=1) do
set @stmt:=concat("select * from ",@a);
prepare stmt from @stmt;
execute stmt;
drop prepare stmt;
fetch cur_2 into f_tablename;
end while;
close cur_2;
END
DATATABLENAME字段存储的是该数据库中的表名,判断从该字段中取出的表名是否在当前数据库中,显示的错误是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 'if exists AA0201_56b31e218d6bf04ca755a83d8c5d4fed' at line 1