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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Concatenating several rows



make it an array first:

SELECT array_to_string(array(SELECT name FROM pseudonyms WHERE
person_id=125), ' '); 


> -----Original Message-----
> From: pgsql-novice-owner(at)postgresql(dot)org 
> [mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of 
> Pierre Thibaudeau
> Sent: Monday, January 29, 2007 6:50 PM
> To: pgsql-novice(at)postgresql(dot)org
> Subject: [NOVICE] Concatenating several rows
> 
> SELECT name FROM pseudonyms WHERE person_id=125;
> 
> I know in advance that this query yields between 0 and 5 rows of
> results, depending on the actual person_id.
> 
> How can I concatenate those results into one text string?  
> Something like:
> 
> SELECT array_to_string( (SELECT name FROM pseudonyms WHERE 
> person_id=125), ' ');
> 
> which doesn't work...
> 



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group