gpt4 book ai didi

mysql - SQL循环连接?

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

如何连接 SQL 列值并用逗号分隔 (', ')

请注意,它也应该以 null 终止。

考虑一个表架构(假设所有数据类型为 varchar(100))

c1s | c2s | c3s | c4s |  c5s  | c6s | c7s
a | b | c | d | null | f | g

所需的输出应为:

a, b, c, d

使用 MySQL Xampp

最佳答案

如果你确实需要这个,你可以使用 CONCAT_WS .

SELECT CONCAT_WS(",", t.foo, t.foo1, t.foo2) AS myfield FROM mytable t

关于mysql - SQL循环连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48189905/

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