Re: new to joins
Hi,
Sorry the order of JOIN was given wrongly....
Tables should be joined in this order
contacts ,events ,contacts
( Xeon's reply would give you primary /secondary ID
And for Xeon , this is a hint...
INNER JOIN -order not important
LEFT/RIGHT JOINs ORDER is important
)
Now ,
SELECT X.lastname,Y.lastname,Z.eventcode
FROM
CONTACTS as X
LEFT OUTER JOIN
EVENTS as Z
ON X.contactId = Z.primary_contactId
LEFT OUTER JOIN
CONTACTS as Y
ON Y.contactId= Z.secondary_contactId;
If you don't want to see Null ADD WHERE Condition ...
or A simple INNER JOIN....
(order not important)
SELECT X.lastname,Y.lastname,Z.eventcode
FROM
EVENTS as Z,CONTACTS as X,CONTACTS as Y
WHERE X.contactId=Z.primary_contactId
AND
Y.contactId=Z.secondary_contactId ;
Regards,
Ram.
We Learn the Most When we have to Invent
Subject
Written By
Posted
September 01, 2004 01:46PM
Re: new to joins
September 01, 2004 10:52PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.