gpt4 book ai didi

mysql - SQL : Using a variable within a text field

转载 作者:行者123 更新时间:2023-11-30 22:55:44 25 4
gpt4 key购买 nike

我是新手,所以请多多包涵。我创建了以下存储过程。

DELIMITER //
CREATE PROCEDURE REMARK()
BEGIN
#declare variable
DECLARE v_newid, v_oldid VARCHAR(255);
DECLARE done INT DEFAULT FALSE;

#declare cursor
DECLARE cur1 CURSOR FOR
SELECT new, old
FROM mydb.`tbl_id`;

#declare handle
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

#open cursor
OPEN cur1;

#starts the loop
the_loop: LOOP

#get the values of each column into our variables
FETCH cur1 INTO v_newid, v_oldid;
IF done THEN
LEAVE the_loop;
END IF;

#Insert it
INSERT INTO cherrycasino.`tbl_remarks` (player_id, user_tool_id, text)
VALUES (v_newid, '103', 'User Copied from ES id:v_oldid');

END LOOP the_loop;

CLOSE cur1;
END //
DELIMITER ;

除一件事外,它正常工作。我想使用从游标获得的变量在 tbl_remarks 中插入一些文本。

VALUES (v_newid, '103', 'User Copied from ES id:v_oldid');

我无法将变量 v_oldid 转换回来。我在这里缺少一些转义序列吗?

最佳答案

原来答案是我想使用的字符串加上变量的简单连接。

VALUES (v_newid, '103', CONCAT('User Copied from ES id:', v_oldid)); 

关于mysql - SQL : Using a variable within a text field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26468049/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com