Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 [Resolved]Table Relationships and Left Outer joins

Author  Topic 

Stuart010
Starting Member

2 Posts

Posted - 2011-11-15 : 06:57:12
Hi all,

I have a bit of an issue relating to combining multiple tables.

Overview
I have a total of 5 tables
1.Applicants
2.Appbankdetails
3.AppltdAddr
4.PersonalDetails
5.UmbrellaCompany

Tables 2,3,4 are left outer joined to table 1 through a common field; My stumbling block is that I need to combine table 5, however a common field only exists between 4 and 5.

I have searched extensively for an answer but I have maybe not phrased my question correctly and would be most grateful if someone could assist. My code so far:-

SELECT *

FROM
ITRIS.dbo.Applicants Applicants

LEFT OUTER JOIN ITRIS.dbo.AppBankDetails AppBankDetails
ON
Applicants.APP_ID = AppBankDetails.APP_ID

LEFT OUTER JOIN ITRIS.dbo.AppLtdAddr AppLtdAddr
ON
Applicants.APP_ID = AppLtdAddr.APP_ID

LEFT OUTER JOIN ITRIS.dbo.PersonalDetails PersonalDetails
ON
Applicants.APP_ID = PersonalDetails.APP_ID

LEFT OUTER JOIN ITRIS.dbo.PersonalDetails PersonalDetails
ON
UmbrellaCompany.ID = PersonalDetails.UMBRELLA_COMPANY_ID

From the above the issue I have relates to the final outer join, should I be using a different syntax?

Regards

Stuart

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-15 : 06:59:00
LEFT OUTER JOIN ITRIS.dbo.UmbrellaCompany UmbrellaCompany
ON
UmbrellaCompany.ID = PersonalDetails.UMBRELLA_COMPANY_ID



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Stuart010
Starting Member

2 Posts

Posted - 2011-11-15 : 07:11:07
Spot on nigelrivett, worked an absolute treat.

Thank you for your help!
Go to Top of Page
   

- Advertisement -