Join master table to multiple related btables

TABLE 1
      table1_ID1,
      tablel_ID2
      
TABLE 2
      table2_ID
      
TABLE 3      
      table3_ID
      
I need to join the three tables.
TABLE 1 is the main table
It want to join to table1 to tablet2 where table1_ID1 = table2_ID
and to join table1 to table3 where table1_ID1 = table3_ID

Only records with values in all three tables should be joined.

I am using DB2

How can this be done?
DaveChoiceTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
select table1_ID1,tablel2_ID,table3_ID
from TABLE1 inner join TABLE2 ON TABLE1.table1_ID2 = TABLE2.tablel2_ID
INNER JOIN TABLE3 ON TABLE2.tablel2_ID = TABLE3.table3_ID
0
Ryan ChongCommented:
I need to join the three tables.
TABLE 1 is the main table
It want to join to table1 to tablet2 where table1_ID1 = table2_ID
and to join table1 to table3 where table1_ID1 = table3_ID
try this....
select TABLE1.*
from TABLE1 inner join TABLE2 ON TABLE1.table1_ID1 = TABLE2.table2_ID
INNER JOIN TABLE3 ON TABLE1.table1_ID1= TABLE3.table3_ID

Open in new window

0
hnasrCommented:
[TABLE 1]
       table1_ID1
       table1_ID2
       
 [TABLE 2]
       table2_ID
       
 [TABLE 3]      
       table3_ID
Guessing:

SELECT  * FROM [TABLE 1] a INNER JOIN [TABLE 2] b ON a.table1_ID1 = b. table2_ID 
INNER JOIN  [TABLE 3] c ON a.table1_ID2 = c.table3_ID

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DaveChoiceTechAuthor Commented:
I had already solved my issue and thought I had deleted the question. All the answers were good so I accepted multiple solutions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.