mysql表名为变量

xiaoxiao2021-02-28  86

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;   //固定格式
转载请注明原文地址: https://www.6miu.com/read-1449983.html

最新回复(0)