Link to home
Start Free TrialLog in
Avatar of techEverest
techEverest

asked on

SQL JOIN

I have 3 tables Table_1,Table_2,Table_3. Table Table_1  has to always be left joined since we want all its data captured all the time.  I just want to make sure I am doing it right.

Requirement
1.Get all the data from table_1,table_2 and table_3
2. Table_1 should be left joined to both table_2 and table_3.

Table_1                          Table_2                                               Table_3
Columns                            Columns                                                Columns
TradeId                            Bk_Id                                                         Jpt_Id
TradeType                 Book Name                                                 Portfolio
                       
Am I doing it right as follows?

Select TradeType,Book Name,Portfolio
FROM Table_1 t1 LEFT JOIN
Table_2  t2 ON t1.TradeId=t2.Bk_Id
LEFT JOIN Table_3 t3 ON t1.TradeId=t3.Jpt_Id
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chris Ashcraft
Yes, your join is syntactically correct ANSI SQL. Just make sure you use the alias names in the join clause (I.e. t1.TradeType)
You should also have square brackets around t2.[Book Name]
Avatar of techEverest
techEverest

ASKER

Thank you all for your prompt response.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for all your help