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
 Old Forums
 CLOSED - General SQL Server
 syntax error in my join statement

Author  Topic 

-Dman100-
Posting Yak Master

210 Posts

Posted - 2006-09-14 : 11:23:04
I'm getting a Syntax error in JOIN operation.

This is the statement:

strSQL = "select currentstatus.status, currentstatus.image, StatusHeader.Url, StatusDescription.Description " & _
"from ((StatusDetails inner join CurrentStatus on statusDetails.currentstatus = currentstatus.statusid) " & _
"(inner join StatusHeader on statusDetails.statusheader = statusheader.HeaderId " & _
"inner join StatusDetails on StatusDetails.StatusDescription = StatusDescription.DescriptionId)) " & _
"where statusdetails.sitename = '" & arg1 & "'"

If I remove the last inner join the statement runs fine:

strSQL = "select currentstatus.status, currentstatus.image, StatusHeader.Url " & _
"from ((StatusDetails inner join CurrentStatus on statusDetails.currentstatus = currentstatus.statusid) " & _
"inner join StatusHeader on statusDetails.statusheader = statusheader.HeaderId) " & _
"where statusdetails.sitename = '" & arg1 & "'"

Any help is appreciated.
Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-14 : 11:29:46
[code]select currentstatus.status,
currentstatus.image,
StatusHeader.Url,
StatusDescription.Description
from StatusDetails
inner join CurrentStatus on statusDetails.currentstatus = currentstatus.statusid
inner join StatusHeader on statusDetails.statusheader = statusheader.HeaderId
inner join StatusDescription StatusDetails on StatusDetails.StatusDescription = StatusDescription.DescriptionId
where statusdetails.sitename = @arg1[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-15 : 10:27:06
Also use stored procedures with parameters. Avoid having concatenated sql statements

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -