mysql在存儲(chǔ)過程中拼接字符串的方法
存儲(chǔ)過程如下:
DELIMITER $$DROP PROCEDURE IF EXISTS `test`$$
CREATE PROCEDURE `test`()
BEGIN
DECLARE sqlQuery VARCHAR(11000);
SET sqlQuery='select ';
SET sqlQuery=CONCAT(firstname,lastname); //拼接firstname與lastname
PREPARE s1 FROM @sql;
EXECUTE s1;
DEALLOCATE PREPARE s1;
END$$
DELIMITER ;