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

Join within INNER JOIN

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
Something not right with this query, please help
Here is the error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

Code:
"SELECT " _
	& "	a.idGroup,a.groupName,a.viewType,a.active, " _
	& "	b.idCust,c.custName " _
	& "	FROM tblGroups a " _
	& "	INNER JOIN tblGroupCust b " _
	& "		INNER JOIN tblCustomers c " _
	& "			ON b.idCust = c.idCust " _
	& "		ON a.idGroup = b.idGroup " _
	& "	ORDER BY a.groupName"
If I remove the inner INNER JOIN, I will get the b.idCust just fine. The c.custName is the problem.

Thanks
 
I found out why and the problem is: missing quotation before tblGroupCust b and after the ON first ON case.

Stupid me! :)
 
Another way:
Code:
"SELECT " _
    & "    a.idGroup,a.groupName,a.viewType,a.active, " _
    & "    b.idCust,c.custName " _
    & "    FROM (tblGroups a " _
    & "    INNER JOIN tblGroupCust b " _
    & "        ON a.idGroup = b.idGroup) " _
    & "    INNER JOIN tblCustomers c " _
    & "        ON b.idCust = c.idCust " _
    & "    ORDER BY a.groupName"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top