pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: how to concat/concat_ws all fields without braces
Date: Sat, 15 Jun 2019 16:36:26 +0700
Message-ID: <1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net> (raw)
In-Reply-To: <20190615061957.GD2565@protected.rcdrun.com>
References: <20190615061957.GD2565@protected.rcdrun.com>

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;








view thread (6+ messages)  latest in thread

Message-ID: <1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net>
Permalink:  ../1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net/
Also on:    postgresql.org/message-id/1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: how to concat/concat_ws all fields without braces
  In-Reply-To: <1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net>
  References: <20190615061957.GD2565@protected.rcdrun.com> <1d492f68-96d7-5062-49b4-227b2fdaf617@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox