有这样一张表:
select * from liutest order by 1;
id | kw
----+--------
1 |
bi
g
1 | hello
2 |
oracle
2 | small
2 | apple
3 | shit
(6 rows)
我想按id把kw拼接成一个字符串,在网上查到一种方法:
select id,
array_to_string
(
ARRAY (
SELECTkw
FROM liutest gi
WHERE gi.id = gd.id
),223)"> ','
) AS group_concat
FROM liutest gd
ORDER BY
id; 原文链接:https://www.f2er.com/postgresql/196113.html