Re: how to concat/concat_ws all fields without braces

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: how to concat/concat_ws all fields without braces
Date: 2019-06-15 09:36:26
Message-ID: 1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jean Louis schrieb am 15.06.2019 um 13:19:
> I have tried doing something like:
>
> SELECT concat_ws(' ', table.*) FROM table;
>
> and if I do that way, it is essentially same as
>
> SELECT concat(table.*) FROM table;
>
> and I get the items in braces like (1,something).
>
> Why do I get it in braces?
>
> Is there a way without specifying specific fields
> to get all items concatenated without braces?
>
> I would prefer conat_ws option.

you can use the json functions for that:

select (select string_agg(x.v, ',') from jsonb_each_text(to_jsonb(t)) as x(k,v)) as all_columns
from the_table t;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Cramer 2019-06-15 10:47:50 Re: arrays of composite types, and client drivers like JDBC
Previous Message Pavel Stehule 2019-06-15 09:36:21 Re: how to concat/concat_ws all fields without braces