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 -> Re: SQL help needed...

Re: SQL help needed...

From: ntalbs <ntalbs_at_gmail.com>
Date: 14 Apr 2005 01:41:14 -0700
Message-ID: <1113468074.252640.133390@z14g2000cwz.googlegroups.com>


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

Original text of this message

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