Re: Join field values

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: veejar <veejar(dot)net(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Join field values
Date: 2007-06-05 17:13:10
Message-ID: 1181063590.7660.103.camel@dogma.v10.wvs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2007-06-05 at 19:33 +0300, veejar wrote:
> Hello!
>
> I have such field in my table:
>
> field1
> -------
> 1
> 2
> 3
> 4
> 5
>
>
> I want to get such result from select:
> '1,2,3,4,5' - join all values in field1 with ','
> // result must be varchar.
>

Look into writing a simple function:

http://www.postgresql.org/docs/current/static/plpgsql.html

Also, consider that you should have an ORDER BY somewhere, to make sure
the values get joined in the order that you expect.

Regards,
Jeff Davis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message volunteer 2007-06-05 17:16:41 Re: lo or bytea streaming engine??
Previous Message Tom Lane 2007-06-05 17:09:46 Re: $libdir