mysql教程

超轻量级php框架startmvc

MySQL 存储过程中执行动态SQL语句的方法

更新时间:2020-04-28 01:05:01 作者:startmvc
dropPROCEDUREifexistsmy_procedure;createPROCEDUREmy_procedure()BEGINdeclaremy_sqllvarchar(500);setmy_sqll='select*fromaa

drop PROCEDURE if exists my_procedure; 
create PROCEDURE my_procedure() 
BEGIN 
 declare my_sqll varchar(500); 
 set my_sqll='select * from aa_list'; 
 set @ms=my_sqll; 
 PREPARE s1 from @ms; 
 EXECUTE s1; 
 deallocate prepare s1; 
end;
MySQL 存储过程 动态SQL