Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outer Join not working in Oracle 8.1.7 1

Status
Not open for further replies.

ModelTrains

Programmer
Nov 12, 2002
40
US
I am trying to join two tables where 4 records exist in one table, but not in the second table. I have done many outer joins in my life in other databases, but I am new to Oracle. Here is an example of the situation:

The EVENT_MAIN table has 4 records:

SELECT E.EVENT_KEY FROM EVENT_MAIN E
WHERE E.EVENT_KEY IN (100000046,100000047,100000048,100000049)

EVENT_KEY
----------
100000046
100000047
100000048
100000049

The SQL I want to work is:

SELECT E.EVENT_KEY, EF.CODE_KEY, EF.FACILITY_KEY
FROM EVENT_MAIN E, EVENT_FACILITY EF
WHERE EF.EVENT_KEY = E.EVENT_KEY(+)
AND EF.CODE_KEY=3
AND E.EVENT_KEY IN (100000046,100000047,100000048,100000049)

EVENT_KEY CODE_KEY FACILITY_KEY
---------- ---------- ------------
100000048 3 100001428
100000049 3 100000613

The desired result is:

EVENT_KEY CODE_KEY FACILITY_KEY
---------- ---------- ------------
100000046
100000047
100000048 3 100001428
100000049 3 100000613

What am I doing wrong?
 
The (+) is on the wrong side:

SELECT E.EVENT_KEY, EF.CODE_KEY, EF.FACILITY_KEY
FROM EVENT_MAIN E, EVENT_FACILITY EF
WHERE EF.EVENT_KEY(+) = E.EVENT_KEY
AND EF.CODE_KEY (+)=3
AND E.EVENT_KEY IN (100000046,100000047,100000048,100000049)
 
THANK YOU, JEE! Actually, this was a sub-select within a much larger SQL statement, but it works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top