Received: from la03.lahost.net ([216.77.80.5]) by hub.org (8.10.1/8.10.1) with ESMTP id e7OIp3539249 for ; Thu, 24 Aug 2000 14:51:03 -0400 (EDT) Received: from crusher (64-204-48-195.client.dsl.net [64.204.48.195]) by la03.lahost.net (Rockliffe SMTPRA 4.2.4) with ESMTP id ; Thu, 24 Aug 2000 13:50:35 -0500 Message-ID: <000a01c00e0d$08429980$c330cc40@crusher> From: "Ryan Williams" To: Cc: References: <200008241824.e7OIOR528066@hub.org> Subject: Re: weird structure Date: Thu, 24 Aug 2000 13:51:08 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200008/267 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: To: Cc: 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 >