欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2024-03-02 10:24:58
drop procedure if exists my_procedure; create procedure my_procedure() begin...
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;