Advanced SELECT

Поиск
Список
Период
Сортировка
От Kai Hessing
Тема Advanced SELECT
Дата
Msg-id 383fk1F5hq3hhU1@individual.net
обсуждение исходный текст
Ответы Re: Advanced SELECT  (Richard Huxton <dev@archonet.com>)
Список pgsql-sql
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.)


В списке pgsql-sql по дате отправления:

Предыдущее
От: Kai Hessing
Дата:
Сообщение: Software for database-visualisation
Следующее
От: "Steve - DND"
Дата:
Сообщение: Junk queries with variables?