我正在尝试在select语句中添加多个动态列(存储过程),但最终无法正常工作,请您帮我一个忙。
BEGIN SET @col1 = col1;SET @col1 = col2;SET @getID = CONCAT('SELECT ' ,@col1 = col1, @col2 = col2,' FROM',tablename_In,' WHERE `type`= type ORDER BY id DESC LIMIT ?,?'); PREPARE stmt FROM @getID;SET @START =_START; SET @LIMIT = _LIMIT;EXECUTE stmt USING @START, @LIMIT; DEALLOCATE PREPARE stmt; END
此外,我还有另一个存储过程,它在查询之间也无法使用:
BEGIN SET @getID = CONCAT('SELECT count(id) as co FROM ',tablename_In,' WHERE',est_time,' BETWEEN',start_date,'AND',end_date);PREPARE stmt FROM @getID; EXECUTE stmt; DEALLOCATE PREPARE stmt; END