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 > Joining more than 2 tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-04, 22:48
deepakatfre deepakatfre is offline
Registered User
 
Join Date: Jun 2004
Posts: 32
Joining more than 2 tables

Hi
UDB 8.05.001

I have 3 tables which I want to join as follows
Table 1
ColA ColB
1 A
2 B
3 C


Table 2
Colc Cold
2 X


Table 3
Cole Colf
3 Z
----------------------------------------------
I know to join two tables which is as follows
select tb1.*, tb2.*
from
SESSION.table1 as tb1
LEFT OUTER JOIN
SESSION.table2 as tb2
on
tb1.colA = tb2.colc
----------------------------------------------
Could anyone give me the syntax for 3 tables I tried couple of things but did
not work.
select tb1.*, tb2.*,tb3.*
from
SESSION.table1 as tb1
LEFT OUTER JOIN
SESSION.table2 as tb2
on
tb1.colA = tb2.colc

I also want to include tb3 and join this on
tb1.colA = tb3.cole



Thanks
Reply With Quote
  #2 (permalink)  
Old 09-04-04, 22:59
deepakatfre deepakatfre is offline
Registered User
 
Join Date: Jun 2004
Posts: 32
I got it.

I got the syntax.
select tb1.*, tb2.*, tb3.*
from
SESSION.table1 as tb1
LEFT OUTER JOIN
SESSION.table2 as tb2
on
tb1.colA = tb2.colc
LEFT OUTER JOIN
SESSION.table3 as tb3
on
tb1.colA = tb3.cole
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