MySQL中能执行动态SQL吗
1个回答
2015-06-27 · 知道合伙人软件行家
关注
展开全部
存储过程中可以!
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;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询