Skip to main content
Known Participant
October 27, 2009
Question

MySQL InnerJoin query syntax error?

  • October 27, 2009
  • 1 reply
  • 1244 views

I can't seem to locate the syntax error in this MySQL query.  Coldfusion says there an error in my sql syntax.  Here is the query.  Anyone have any clues on this?

<cfquery name="queryItem" datasource="bonus">

select

p.productid,

p.modelnumber,

p.modeldescription,

sp.sp_bonusamount as Amount

from

products i join bonusproducts sp on i productid = sp.sp_productid

inner join program p on sp.sp_programid = p.programid

where

p.CompanyOrgLevelID in (#getParentCompanyOrgLevelIDList(session.CompanyOrgLevelID)#)

and p.ProgramID = #programID#

<cfif categoryID gt 0>

and CategoryID in (#getSubcategoryIDList(categoryID)#)

</cfif>

order by

#sortColumn# #sortDirection#

</cfquery>

This topic has been closed for replies.

1 reply

Inspiring
October 27, 2009

What does the error message say?

What are the values of all your variables?

Known Participant
October 27, 2009

the error says-

Error Executing Database Query.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on i productid = sp.sp_productid inner join program p on sp.sp_programid = p.' at line 8

Inspiring
October 28, 2009

What is the value of getParentCompanyOrgLevelIDList(session.CompanyOrgLevelID)?  Could it ever be null or an empty string?  That would invalidate your SQL.

--

Adam