I'm trying to join all results from one column in SELECT
query into one string.
Some of you might be familiar with C#
:
string.Join(separator, stringArray)
The following statement doesn't return all results as one string
SELECT CONCAT(text) FROM orders
Does anyone have an idea of how to replicate that C#
code by means of SQL
?
You are looking for string_agg()
:
select string_agg(text separator, ',')
from orders;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.