Skip site navigation (1) Skip section navigation (2)

Re: Concatenate rows

From: A Gilmore <agilmore(at)shaw(dot)ca>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Concatenate rows
Date: 2005-02-21 19:19:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Michael Fuhr wrote:
> On Sun, Feb 20, 2005 at 05:32:48PM -0800, A Gilmore wrote:
>>If I have a table like :
>>1	blue
>>2	red
>>3	green
>>Could I write a SQL query that would return a single concatenated row 
>>for all matching rows, with a specified seperator. For example like so :
> In PostgreSQL 7.4 and later you could do this:
> SELECT array_to_string(array(SELECT color FROM foo), ':');
> See "Array Constructors", "Arrays", and "Array Functions and
> Operators" in the documentation.  Here are links for the latest
> version of PostgreSQL:

That works great, thank you very much.  I had been reading over the much 
documentation but mistakenly skipped arrays assuming it wouldn't be 

A Gilmore

In response to

pgsql-novice by date

Next:From: David J KirolDate: 2005-02-21 19:47:17
Subject: createlang fails
Previous:From: Larry RosenmanDate: 2005-02-21 16:42:48
Subject: Re: operator class for user defined type

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group