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

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

WBOY
WBOYOriginal
2016-06-07 16:28:37921browse

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;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn