mysql在存储过程中拼接字符串的方法
存储过程如下:
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 ;