X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 783058B9E65 for ; Wed, 23 Feb 2005 13:43:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00196-06 for ; Wed, 23 Feb 2005 13:43:29 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) by svr1.postgresql.org (Postfix) with ESMTP id 72E918B9E42 for ; Wed, 23 Feb 2005 13:43:31 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 36AD631DD2; Wed, 23 Feb 2005 14:43:31 +0100 (MET) From: Kai Hessing X-Newsgroups: pgsql.sql Subject: Advanced SELECT Date: Wed, 23 Feb 2005 14:43:25 +0100 Lines: 49 Message-ID: <383fk1F5hq3hhU1@individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) X-Accept-Language: de, en-us, en X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200502/289 X-Sequence-Number: 20399 Hi Folks, I hope to have found the right group for my question. I have difficult sql-task. I try to describe it simple: We have a table 'company' with a cid and a table 'sector' with a sid. They are connected m:n via a third table 'company_sector' which contians csid, cid and sid. The normal clause would look like: SELECT c.companyname, s.sectorname FROM company c, sector s, company_sector cs WHERE cs.cid = c.cid AND cs.sid = s.sid ORDER BY c.companyname; This gives a result looking like this: c.companyname | s.sector ---------------+------------------------ company1 | sectora company1 | sectorb company2 | sectora company2 | sectorb company2 | sectorc company3 | sectora company4 | sectorc instead of this I want to have a listing like: c.companyname | ??? (sectors) ---------------+------------------------ company1 | sectora, sectorb company2 | sectora, sectorb, sectorc company3 | sectora company4 | sectorc But I have no idea, how to write a SELECT-command that gives a listing like this :( Maybe anyone can help *please* *Thanks and greetings* Kai... -- GnuPG-PublicKey -> http://www.hobsons.de/pgp/kai_hessing.asc Unzeitige Genuesse erzeugen Ekel. (Demokrit, um 460 v. Chr.)