Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> SQL Query help
I have 3 tables:
PEM
PES
PP
--- PP_PK_ID ENC_ID (Foreign Key to PEM.ENC_ID; can be null) I need to do a join between PEM.ENC_ID and PES.ENC_ID and find all the PES records that have a ENC_ID, so I do this: SELECT PEM.ENC_ID FROM PEM.ENC_ID WHERE PEM.ENC_ID = PES.ENC_ID AND PEM.GRP_ID = 500 ..and that works fine and if I did a count would return around 150,000 records. What I need to find out now is what PEM records in the above recordset have no PP.ENC_ID's associated with them. I've tried something like this: SELECT PEM.ENC_ID FROM PEM.ENC_ID WHERE PEM.ENC_ID = PES.ENC_ID AND PEM.ENC_ID = PP.ENC_ID(+) AND PP.ENC_ID Is NULL AND PEM.GRP_ID = 500 But the statement takes forever to run and I'm thinking I'm getting a cartesian product back somehow. TIA. -- Posted via dBforums http://dbforums.comReceived on Tue Mar 12 2002 - 15:13:33 CST