Re: how to concat/concat_ws all fields without braces - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: how to concat/concat_ws all fields without braces
Date
Msg-id 1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net
Whole thread Raw
In response to how to concat/concat_ws all fields without braces  (Jean Louis <bugs@gnu.support>)
Responses Re: how to concat/concat_ws all fields without braces
List 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;






pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: how to concat/concat_ws all fields without braces
Next
From: Dave Cramer
Date:
Subject: Re: arrays of composite types, and client drivers like JDBC