20  
查询码: 00000618
MYSQL存储过程中 使用变量 做表名 - Boblim - 博客园
来源:https://www.cnblogs.com/fnlingnzb-learner/p/6343316.html
作者: 周杨 于 2022年06月02日 发布在分类 / 计算机应用 / 数据库 / MySql ,于 2022年06月02日 编辑

DECLARE temp1 varchar(30);
DECLARE temp2 int;
set temp1=m_tableName;
set temp2=m_maxCount;
set @sqlStr=CONCAT('select * from ',temp1,' limit ',temp2);
PREPARE stmt from @sqlStr;
EXECUTE stmt;




 历史版本

备注 修改日期 修改人
CREAT 2022-06-02 14:04:28[当前版本] 系统管理员

知识分享平台 -V 5.1.4 -大信谛威