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

Home -> Community -> Usenet -> c.d.o.server -> SQL help needed...

SQL help needed...

From: Raj <andhra_abbai23_at_yahoo.com>
Date: 13 Apr 2005 20:08:42 -0700
Message-ID: <1113448122.667449.44070@l41g2000cwc.googlegroups.com>


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 SQL will give me 5 and 8 in the above example. For First ID = 9 the SQL will give me 11.
Any help will be greatly appreciated. Thanks!!

-Raj Received on Wed Apr 13 2005 - 22:08:42 CDT

Original text of this message

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