使用 group_concat 在新行上显示每个值而不是相同的值
Display each value on new lines instead of same using group_concat
我有以下查询来显示结果:
SELECT C.Customer_ID
, group_concat(CP.Company_description separator '\n') as companyName
FROM tbl_Customer AS C
JOIN tbl_Company AS CP
ON (CP.Customer_ID = C.Customer_ID)
group
by Customer_ID
我得到了想要的结果,但是结果显示为这样。
Customer_ID
companyName
1
test1, test2, test3
2
test4, test5, test6
我希望结果像这样换行显示
Please Click Here to Refer to What I am Looking for
所以为了更清楚,我在新行上显示了 test1、test2、test3,如:
测试1
测试2
测试3
只需在组中添加另一列。像这样
SELECT C.Customer_ID, CP.Company_description 作为公司名称
来自 tbl_Customer 作为 C
内部加入tbl_Company作为CP
开 (CP.Customer_ID = C.Customer_ID)
按Customer_ID、CP.Company_description
分组
我有以下查询来显示结果:
SELECT C.Customer_ID
, group_concat(CP.Company_description separator '\n') as companyName
FROM tbl_Customer AS C
JOIN tbl_Company AS CP
ON (CP.Customer_ID = C.Customer_ID)
group
by Customer_ID
我得到了想要的结果,但是结果显示为这样。
Customer_ID | companyName |
---|---|
1 | test1, test2, test3 |
2 | test4, test5, test6 |
我希望结果像这样换行显示
Please Click Here to Refer to What I am Looking for
所以为了更清楚,我在新行上显示了 test1、test2、test3,如:
测试1
测试2
测试3
只需在组中添加另一列。像这样
SELECT C.Customer_ID, CP.Company_description 作为公司名称
来自 tbl_Customer 作为 C
内部加入tbl_Company作为CP
开 (CP.Customer_ID = C.Customer_ID)
按Customer_ID、CP.Company_description
分组