mysql 表名为变量

SET @process_form = 10;

SET @run_id = 1665;

//表名为变量时,拼装sql

SET @data_sql = CONCAT('SELECT * FROM home_',@process_form,' WHERE id = ',@run_id);  

PREPARE stmt FROM @data_sql;   //固定格式

EXECUTE stmt;   //固定格式
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页