Skip site navigation (1) Skip section navigation (2)

Re: weird structure

From: "Ryan Williams" <shrewsbury(at)louisiana(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: <rdg(at)viafractal(dot)com(dot)br>
Subject: Re: weird structure
Date: 2000-08-24 20:51:08
Message-ID: 000a01c00e0d$08429980$c330cc40@crusher (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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(at)viafractal(dot)com(dot)br>
To: <pgsql-sql(at)postgresql(dot)org>
Cc: <rdg(at)viafractal(dot)com(dot)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(at)viafractal(dot)com(dot)br

In response to


pgsql-sql by date

Next:From: Renato De GiovanniDate: 2000-08-24 22:15:35
Subject: Re: weird structure
Previous:From: Stephan SzaboDate: 2000-08-24 18:45:19
Subject: Re: Question on string value expression wildcarding

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group