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
 Old Forums
 CLOSED - General SQL Server
 syntax error in my join statement
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

-Dman100-
Posting Yak Master

209 Posts

Posted - 09/14/2006 :  11:23:04  Show Profile
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

Sweden
30187 Posts

Posted - 09/14/2006 :  11:29:46  Show Profile  Visit SwePeso's Homepage
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

Peter Larsson
Helsingborg, Sweden

Edited by - SwePeso on 09/14/2006 11:30:03
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 09/15/2006 :  10:27:06  Show Profile  Send madhivanan a Yahoo! Message
Also use stored procedures with parameters. Avoid having concatenated sql statements

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000