【问题标题】:MySql select all records and show in a single column with comma seperator [duplicate]MySql选择所有记录并用逗号分隔符显示在单列中[重复]
【发布时间】:2017-05-14 18:33:28
【问题描述】:

我的MySql表是这样的;

id    name
1     test1
2     test2
3     test3

我想写一个 tsql 并像这样列出它们;

测试1,测试2,测试3

有可能吗?谢谢。

【问题讨论】:

标签: mysql list select comma separator


【解决方案1】:

在 MySQL 中,您可以像这样使用GROUP_CONCAT

select group_concat(name separator ',') from table;

【讨论】:

    猜你喜欢
    • 2014-08-08
    • 2020-12-16
    • 2013-03-06
    • 1970-01-01
    • 2012-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多