Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with SQL inner join statement 1

Status
Not open for further replies.

serino

Programmer
Feb 13, 2003
107
US
I have this query and it worked fine except until I add one more criteria "J.Code1" to the statement below and now I am receiving a syntax error message. I am not sure how to fix this.

SELECT R.PID, R.Total AS RTotal, L.Total AS LTotal, F.Total AS FTotal, J.Total AS JTotal
FROM (Group_Reason_Table AS R
INNER JOIN Group_Reason_Table AS L ON R.PID = L.PID)
INNER JOIN Group_Reason_Table AS F ON R.PID = F.PID
INNER JOIN Group_Reason_Table AS J ON R.PID = J.PID
WHERE R.Code1 = '0.0'
AND L.Code1 = '1.1'
AND F.Code1 = '4.1'
AND J.Code1 = '4.4'


Syntax_Error_otdom9.png


Your help is appreciated, thank you!
 
I believe you will need to put parenthesis around the second join:
from ((Group_Reason_Table

and then

R.PID = F.PID)

so it looks like this:

SELECT R.PID, R.Total AS RTotal, L.Total AS LTotal, F.Total AS FTotal, J.Total AS JTotal
FROM ((Group_Reason_Table AS R
INNER JOIN Group_Reason_Table AS L ON R.PID = L.PID)
INNER JOIN Group_Reason_Table AS F ON R.PID = F.PID)
INNER JOIN Group_Reason_Table AS J ON R.PID = J.PID
WHERE R.Code1 = '0.0'
AND L.Code1 = '1.1'
AND F.Code1 = '4.1'
AND J.Code1 = '4.4'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top