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.
Author |
Topic |
Niki
Yak Posting Veteran
51 Posts |
Posted - 2012-12-05 : 18:32:20
|
Is it possible to have nested joins like below. It is giving me error though.Select S.IDFROM 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.IDThe error I am getting is 'Incorrect syntax near 'P'.Niki |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-12-05 : 18:40:04
|
Would this work? I'm not sure which table you are trying to alias as "P".[CODE]Select S.IDFROM dbo.tblssms S LEFT JOIN ([DBname].[dbo].[tblAdditionalPrograms] PINNER JOIN [DBname].[dbo].[tblAdditionalProgramsDefs] ON P.[RecCodeID] = [DBname].[dbo].[tblAdditionalProgramsDefs].[ID]) ON S.ID = P.ID[/CODE]=================================================Hear the sledges with the bells - silver bells! What a world of merriment their melody foretells! |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-05 : 20:02:51
|
You mean this one Select S.IDFROM 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 |
 |
|
Niki
Yak Posting Veteran
51 Posts |
Posted - 2012-12-06 : 11:11:48
|
Yes, Sodeep.Thank you! it worked.Niki |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-06 : 12:13:37
|
quote: Originally posted by Niki Yes, Sodeep.Thank you! it worked.Niki
NP |
 |
|
|
|
|