SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Question on nested joins
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Niki
Yak Posting Veteran

51 Posts

Posted - 12/05/2012 :  18:32:20  Show Profile  Reply with Quote
Is it possible to have nested joins like below. It is giving me error though.

Select S.ID
FROM dbo.tblssms S LEFT JOIN
([DBname].[dbo].[tblAdditionalPrograms]
INNER JOIN [DBname].[dbo].[tblAdditionalProgramsDefs]
ON [DBname].[dbo].[tblAdditionalPrograms].[RecCodeID] = [DBname].[dbo].[tblAdditionalProgramsDefs].[ID])
P ON S.ID = P.ID

The error I am getting is 'Incorrect syntax near 'P'.


Niki

Bustaz Kool
Flowing Fount of Yak Knowledge

USA
1696 Posts

Posted - 12/05/2012 :  18:40:04  Show Profile  Reply with Quote
Would this work? I'm not sure which table you are trying to alias as "P".
Select S.ID
FROM dbo.tblssms S LEFT JOIN 
([DBname].[dbo].[tblAdditionalPrograms] P
INNER JOIN [DBname].[dbo].[tblAdditionalProgramsDefs] 
ON P.[RecCodeID] = [DBname].[dbo].[tblAdditionalProgramsDefs].[ID])
 ON S.ID = P.ID



=================================================
Hear the sledges with the bells - silver bells!
What a world of merriment their melody foretells!
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/05/2012 :  20:02:51  Show Profile  Reply with Quote
You mean this one

Select S.ID
FROM dbo.tblssms S 
LEFT JOIN 
(
Select ID,* from [DBname].[dbo].[tblAdditionalPrograms] 
INNER JOIN [DBname].[dbo].[tblAdditionalProgramsDefs] ON [DBname].[dbo].[tblAdditionalPrograms].[RecCodeID] = [DBname].[dbo].[tblAdditionalProgramsDefs].[ID]
)P ON S.ID = P.ID
Go to Top of Page

Niki
Yak Posting Veteran

51 Posts

Posted - 12/06/2012 :  11:11:48  Show Profile  Reply with Quote
Yes, Sodeep.
Thank you! it worked.

Niki

Edited by - Niki on 12/06/2012 11:39:03
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/06/2012 :  12:13:37  Show Profile  Reply with Quote
quote:
Originally posted by Niki

Yes, Sodeep.
Thank you! it worked.

Niki



NP
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000