Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Tricky SQL question

Re: Tricky SQL question

From: <terencefinn_at_my-dejanews.com>
Date: 1998/11/04
Message-ID: <71qk60$36b$1@nnrp1.dejanews.com>#1/1

The only way I can think of doing this is by creating a third intermediate table to work with. Containing three columns (id, Person, Attributes). Fill Id and Person with the valid values from the people table. Then loop through the table fetching the attributes for each row. After you fetch each attribute concatenate it in a variable to the attributes you have. After each person upate your table with the attributes for the row from the variable. And so on. This is the only way I can think of doing it. Sorry if I didn't explain it very clearly.

In article <3640a959.4517586_at_resunix.sickkids.on.ca>,   joost.ouwerkerk_at_sickkids.on.ca (Joost Ouwerkerk) wrote:
> Given two tables: people (Person, ID) and attributes (ID, attribute)
>
> A person can have any number of attributes:
>
> ID Attribute
> --- ---------
> 123 Man
> 123 Actor
> 123 Consumer
>
> How can I get the following output using only SQL (SQL*Plus):
>
> Person ID Attributes
> -------------------------- --- ---------------------------------
> Joe Jones 123 Man, Actor, Consumer
> Mary Walsh 234 Woman, Comedian, Writer, Director
> Jackie Chan 456 Man, Martial Artist
> Larry Sanders 678 Man, Comedian, Producer
>
> The attributes must be on one line and separated by commas. Is this
> even possible?
>
> Joost Ouwerkerk
> Hospital For Sick Children Foundation
> Toronto, Canada
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Nov 04 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US