If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Outer joins

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-12-04, 09:35
banjoke banjoke is offline
Registered User
 
Join Date: Oct 2004
Posts: 5
Outer joins

Hi

I need to use an outerjoin to join 2 tables but they need to be joined based on 2 colums.

tablea: tableb:
col1 col1
col2 col2
col3 cola
col4 colb
... ...


so they need to be joinen basen on col1 and col2

select count(*)
from tablea a
left outer join tableb b
on a.col1 = b.col1
....

the rest i'm unable to find... could someone help me with this?

regards
Reply With Quote
  #2 (permalink)  
Old 10-12-04, 09:42
Filip Poverud Filip Poverud is offline
Registered User
 
Join Date: Oct 2004
Location: Norway
Posts: 53
SELECT ... FROM TBLA A LEFT OUTER JOIN TBLB B ON B.COL1 = A.COL1 AND B.COL2 = A.COL2 WHERE ...

This is one alternative ...

Beware of the keyword AND in JOIN conditions versus using the WHERE clause.

---
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On