gpt4 book ai didi

mysql - 在 mysql 中连接结果值

转载 作者:行者123 更新时间:2023-11-29 00:26:04 25 4
gpt4 key购买 nike

我可以连接结果值,然后将最终值作为输出发送吗?

WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = CONCAT(totalshipmentexpenseamount,',',indshipmentexpenseamount);
END;
END WHILE;

但最后 totalshipmentexpenseamount 没有任何值(value)。

最佳答案

不知道您提供的代码之前是什么,但您可以尝试以下操作:

WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = CONCAT(COALESCE(totalshipmentexpenseamount, ''),',',indshipmentexpenseamount);
END;
END WHILE;

这是因为 totalshipmentexpenseamount 第一次设置为 null 并且当你将 null 与其他东西连接时它会出现 。如果 totalshipmentexpenseamountnull

coalesce 将返回空

编辑:

改成这个

WHILE(LENGTH(totalexpenseamount )>0) DO
BEGIN
SET totalshipmentexpenseamount = COALESCE(CONCAT(totalshipmentexpenseamount,',',indshipmentexpenseamount), indshipmentexpenseamount);
END;
WHILE;

由于您使用逗号连接,这将在第一次传递时设置 indshipmentexpenseamount 的值,否则将使用逗号连接 totalshipmentexpenseamountindshipmentexpenseamount

关于mysql - 在 mysql 中连接结果值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18866864/

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