From: virgi@lettere.unipd.it
To: pgsql-sql@postgresql.org
Subject: How to get a result in one row
Date: Wed, 21 Jun 2006 17:06:12 +0200
Message-ID: <20060621150612.GA6246@fedro.lettere.unipd.it> (raw)
Hi!
I'm using PostgreSQL 7.4.7.
table_c
id | nick
----+------
1 | T
2 | S
3 | G
4 | A
5 | D
...
table_m
id | c
------+----
22192 | 4
15041 | 3
21764 | 5
22192 | 1
15041 | 4
15041 | 2
...
where table_m.c is a foreign key on table_c.id
SELECT table_m.id,table_c.nick
FROM table_m AS m JOIN table_c AS c ON c.id=m.c
WHERE m.id=22192
ORDER BY c.nick;
returns:
id | nick
------+------
22192 | A
22192 | T
(2 rows)
I'd like to get the result in only one row:
id | nick
------+------
22192 | A,T
(and similarly: 15041 | A,G,S )
As table_c can increase, I don't want to use the case construct.
How can I do? Maybe writing a function. But how?
TIA!
virgi
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: virgi@lettere.unipd.it
Subject: Re: How to get a result in one row
In-Reply-To: <20060621150612.GA6246@fedro.lettere.unipd.it>
* 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