当前位置:Gxlcms > mysql > MySQL存储过程中执行动态SQL语句的方法

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

时间:2021-07-01 10:21:17 帮助过:17人阅读

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;

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;

人气教程排行