i've got below mysql query, it's causing error, error below too.
select distinct s.id id, s.auctioneer auctioneer, s.adverttype adverttype, s.saletype saletype, an.name auctioneername, st.entrycopy saletypename, at.entrycopy adverttypename, s.heading heading, sl.city city, sd.id sdid, sd.startdate startdate sales s left join saleloc sl on sl.saleid = s.id left join saledates sd on sd.saleloc = sl.id, auctioneers an, lookupcopy st, lookupcopy @ #replace(findwhere,"''","'","all")# , s.id = sd.saleid , sl.saleid = s.id , an.id = s.auctioneer , st.id = s.saletype , at.id = s.adverttype group id order startdate, auctioneername, city
error database
select distinct s.id id, s.auctioneer auctioneer, s.adverttype adverttype, s.saletype saletype, an.name auctioneername, st.entrycopy saletypename, at.entrycopy adverttypename, s.heading heading, sl.city city, sd.id sdid, sd.startdate startdate sales s left join saleloc sl on sl.saleid = s.id left join saledates sd on sd.saleloc = sl.id, auctioneers an, lookupcopy st, lookupcopy @ 'where s.adverttype > 0 , s.saletype > 0 , sl.region = "2" ' , s.id = sd.saleid , sl.saleid = s.id , an.id = s.auctioneer , st.id = s.saletype , at.id = s.adverttype group id order startdate, auctioneername, city
i didn't write code , i'm not sure why #replace()# being used, can see how fix syntax error it's causing?
before query code, replace follows: <cfset findwhere = replace(findwhere, "''", "'", "all")# <cfif left(findwhere, 1) eq "'"> <cfset findwhere = right(findwhere, len(findwhere) - 1)> </cfif> <cfif right(findwhere, 1) eq "'"> <cfset findwhere = left(findwhere, len(findwhere) - 1)> </cfif> <cfquery name="qry" datasource="mysql"> select distinct s.id id, s.auctioneer auctioneer, s.adverttype adverttype, s.saletype saletype, an.name auctioneername, st.entrycopy saletypename, at.entrycopy adverttypename, s.heading heading, sl.city city, sd.id sdid, sd.startdate startdate sales s left join saleloc sl on sl.saleid = s.id left join saledates sd on sd.saleloc = sl.id, auctioneers an, lookupcopy st, lookupcopy @ #findwhere# , s.id = sd.saleid , sl.saleid = s.id , an.id = s.auctioneer , st.id = s.saletype , at.id = s.adverttype group id order startdate, auctioneername, city </cfquery>
Comments
Post a Comment