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 Query help

SQL Query help

From: markag <member_at_dbforums.com>
Date: 12 Mar 2002 15:13:33 -0600
Message-ID: <3c8e6f7d$1_2@spamkiller.newsgroups.com>


I have 3 tables:

PEM



ENC_ID (Primary Key) GRP_ID

PES



PES_PK_ID ENC_ID (Foreign Key to PEM.ENC_ID; can be null)

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.com
Received on Tue Mar 12 2002 - 15:13:33 CST

Original text of this message

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