| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help needed...
On 2005-04-14, Raj <andhra_abbai23_at_yahoo.com> wrote:
> Hi,
>
>
> I have a table in which two fields(FirstID, SecondID) together make the
>
> primary key for the table. Let's look at the following example:
>
>
> FirstID SecondID
> ******* ********
> 2 2
> 2 3
> 2 5
> 5 5
> 5 7
> 8 7
> 9 10
> 11 12
>
>
> Here is what I am trying to do. For a given FirstID (say, 2) find all
> SecondID with this FirstID (2,3,5). Now for these second ID's is there
> a FirstID other than 2? (Yes, 5). I would say FirstID=2 is related to
> FirstID = 5. Extending the logic FirstID = 5 is related to FirstID = 8.
>
> I am trying to write a SQL (some kind of self join, I think) which will
> give me all related FirstID for a given First ID. For First ID = 2 the
> .....For First ID = 9 the SQL
> will give me 11.
Why? Either your dataset is incomplete or you failed to descibe your logic accurate enough for me to understand.
Rene
-- Rene Nyffenegger http://www.adp-gmbh.ch/Received on Wed Apr 13 2005 - 23:24:45 CDT
![]() |
![]() |