list variable attributes in one select

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: list variable attributes in one select
Date: 2007-01-22 07:43:48
Message-ID: 20070122074348.GA8177@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

I've got the following tables:

person:
- id_person
- firstname
- lastname
- type

person_to_type:
- id_person references person
- type references person_type;

person_type:
- type

"person_type" contains differents caracteristics for a person (actor,
director, author, etc.) who can have several types, hence the need for
the person_to_type table.

I'd like to know if I can list in one SELECT command a person and all of
its types, given that the number of types can be 0 to n.

For example, for a given person I'd like to obtain:

"John Doe", "actor", "playright", "author"

or

"Jane Doe", "director"

in one select.

Is that possible?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2007-01-22 08:24:02 Re: list variable attributes in one select
Previous Message Tom Lane 2007-01-22 03:36:48 Re: Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?