pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ryan Williams <shrewsbury@louisiana.com>
To: pgsql-sql@postgresql.org
Cc: rdg@viafractal.com.br
Subject: Re: weird structure
Date: Thu, 24 Aug 2000 13:51:08 -0700
Message-ID: <000a01c00e0d$08429980$c330cc40@crusher> (raw)
References: <200008241824.e7OIOR528066@hub.org>

Does it have to be in one row?

Otherwise, assuming that person_data.d_person_id references person.a_id and
person_data.d_attribute_id references person_attribute.a_id:

select a.a_name from person p, person_data d, person_attribute a where
p.p_name = 'UserYou'reLookingFor' AND p.p_id = d.d_person_id AND
d.d_attribute_id = a.a_id

Would return a list of attributes the person has, one per row.

----- Original Message -----
From: <rdg@viafractal.com.br>
To: <pgsql-sql@postgresql.org>
Cc: <rdg@viafractal.com.br>
Sent: Thursday, August 24, 2000 11:24 AM
Subject: [SQL] weird structure


> Hi,
>
> Consider the following tables/fields:
> table "person": fields "p_id", "p_name".
> table "person_attribute": fields "a_id", "a_name".
> table "person_data": fields "d_person_id", "d_attribute_id",
> "d_value".
>
> Also consider that a person may not have data related to all possible
> attributes.
>
> Using this structure, how could I retrieve in one row with a single
> select statement all attributes from a person (showing null to
> attributes that were not registered to him)?
>
> Thanks for any suggestion,
> --
> Renato
> Sao Paulo - SP - Brasil
> rdg@viafractal.com.br
>




view thread (6+ messages)  latest in thread

Message-ID: <000a01c00e0d$08429980$c330cc40@crusher>
Permalink:  ../000a01c00e0d$08429980$c330cc40@crusher/
Also on:    postgresql.org/message-id/000a01c00e0d$08429980$c330cc40@crusher

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: shrewsbury@louisiana.com, rdg@viafractal.com.br
  Subject: Re: weird structure
  In-Reply-To: <000a01c00e0d$08429980$c330cc40@crusher>
  References: <200008241824.e7OIOR528066@hub.org> <000a01c00e0d$08429980$c330cc40@crusher>

* 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