On PostgreSQL 11, I’d like to output the rows of a table as a comma-separated list of strings:
id,info,name,message
I tried the following query:
SELECT array_to_string(array_agg(t), ',', '')
FROM (
SELECT id, info, name, message
FROM myschema.mytable
) t;
But this outputs:
(1,foo,bar,baz),(2,qux,zap,xen)
In constrast, the desired result should look like:
1,foo,bar,baz
2,qux,zap,xen
What would be the correct query?