Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help needed...
I'm not sure the following SQL would do what you want.
SELECT *
FROM tbl
WHERE SecondID in (SELECT SecondID FROM tbl WHERE FirstID=:firstID)
AND FirstID <> :firstID
With this SQL, you can get the following results:
* When FirstID=2, you find SecondIDs (2,3,5),
and with these SecondIDs you can find the FirstID other than 2 is 5.
* When FirstID=5, you find SecondIDs (5,7),
and with these, you can find the FirstIDs other than 5 are (2,8).
* When FirstID=9, you find SecondID 10,
and with this SecondID, you can find only one FirstID(=9), which is
the same
as what you specified.
As Rene said, your description seems to be incomplete or has some fault. Received on Thu Apr 14 2005 - 03:41:14 CDT