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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in Join Operation 1

Status
Not open for further replies.

Xzibit7

Technical User
Jun 20, 2006
172
US
I have a query that works perfectly now, However I am trying to add another field from a table and I keep getting an error message that says Syntax error in Join operation, when I try to save the changes. The problem is even if I just erase one letter from the original sql statement and then put it back the same way, when I try to save it the same error message pops up. Here is the SQL statement

SELECT S.*
FROM ([SELECT Supervisor.ID, Supervisor.NIIN, Supervisor.Nomenclature, Supervisor.Assignment, Supervisor.[Date Assigned], Supervisor.Closed, Supervisor.Requestor, Supervisor.[Requestor Email], Employee.[Follow-Up Date], Supervisor.[Anticipated Completion Date], Supervisor.AssignedTo
FROM Supervisor LEFT JOIN Employee ON Supervisor.ID = Employee.ID
WHERE (((Supervisor.Closed)=No))]. AS S INNER JOIN Userinfo AS U ON S.assignedto=U.username) INNER JOIN Userinfo AS C ON U.GroupId=C.GroupId
WHERE C.username = CurrentUser();
 
Its because Access puts the characters in [red]red[/red] in place of parentheses.
Code:
SELECT S.*
FROM ([red][[/red]SELECT Supervisor.ID, Supervisor.NIIN, Supervisor.Nomenclature, Supervisor.Assignment, Supervisor.[Date Assigned], Supervisor.Closed, Supervisor.Requestor, Supervisor.[Requestor Email], Employee.[Follow-Up Date], Supervisor.[Anticipated Completion Date], Supervisor.AssignedTo
FROM Supervisor LEFT JOIN Employee ON Supervisor.ID = Employee.ID
WHERE (((Supervisor.Closed)=No))[red]].[/red] AS S INNER JOIN Userinfo AS U ON S.assignedto=U.username) INNER JOIN Userinfo AS C ON U.GroupId=C.GroupId
WHERE C.username = CurrentUser();
which should be
Code:
SELECT S.*
FROM ([red]([/red]SELECT Supervisor.ID, Supervisor.NIIN, Supervisor.Nomenclature, Supervisor.Assignment, Supervisor.[Date Assigned], Supervisor.Closed, Supervisor.Requestor, Supervisor.[Requestor Email], Employee.[Follow-Up Date], Supervisor.[Anticipated Completion Date], Supervisor.AssignedTo
FROM Supervisor LEFT JOIN Employee ON Supervisor.ID = Employee.ID
WHERE (((Supervisor.Closed)=No))[red])[/red] AS S INNER JOIN Userinfo AS U ON S.assignedto=U.username) INNER JOIN Userinfo AS C ON U.GroupId=C.GroupId
WHERE C.username = CurrentUser();
The only solution that I know of (apart from changing the statement back to the second form manually) is to make the sub-query a separate query.
Save this as [blue]qrySupvEmp[/blue] (for example)
Code:
SELECT Supervisor.ID, Supervisor.NIIN, Supervisor.Nomenclature, Supervisor.Assignment, Supervisor.[Date Assigned], Supervisor.Closed, Supervisor.Requestor, Supervisor.[Requestor Email], Employee.[Follow-Up Date], Supervisor.[Anticipated Completion Date], Supervisor.AssignedTo
FROM Supervisor LEFT JOIN Employee ON Supervisor.ID = Employee.ID
WHERE (((Supervisor.Closed)=No))
And then
Code:
SELECT S.*
FROM qrySupvEmp AS S INNER JOIN Userinfo AS U 
     ON S.assignedto = U.username 
     INNER JOIN Userinfo AS C 
     ON U.GroupId=C.GroupId
WHERE C.username = CurrentUser();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top