X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 11D019FB1BD for ; Wed, 21 Jun 2006 14:50:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 27824-02 for ; Wed, 21 Jun 2006 14:50:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fedro.lettere.unipd.it (fedro.lettere.unipd.it [147.162.44.1]) by postgresql.org (Postfix) with SMTP id 4448A9F9CC1 for ; Wed, 21 Jun 2006 14:50:21 -0300 (ADT) Received: (qmail 12854 invoked by uid 2772); 21 Jun 2006 17:06:12 +0200 From: virgi@lettere.unipd.it Date: Wed, 21 Jun 2006 17:06:12 +0200 To: pgsql-sql@postgresql.org Subject: How to get a result in one row Message-ID: <20060621150612.GA6246@fedro.lettere.unipd.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/238 X-Sequence-Number: 25474 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