gpt4 book ai didi

mysql: CONCAT_WS 从其他表中选择

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

通常我们使用 concat_ws 将同一个表上的 2 个字段连接到 1 个字符串中,我如何进行查询以从其他表中选择字段值?

GROUP_CONCAT(CONCAT_WS(' - ', item1_from_this_table, item_2_from_other_table) SEPARATOR '\n')

这可能吗?

最佳答案

连接表,然后(如果有歧义)对您的列引用进行表限定:

SELECT GROUP_CONCAT(
CONCAT_WS(' - ', t1.item, t2.item)
SEPARATOR '\n'
)
FROM t1 JOIN t2 ON ...

关于mysql: CONCAT_WS 从其他表中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19647544/

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