If you look at the SQL statement as it was parsed you can see that it isn't valid sql immediately. select * from candidate where else select * from advertiser where if 2 = 1 if 1 eq 1 first_name like '%mystring%' or last_name like '%mystring%' else company_name like '%mystring%' else if 2 = 2 if 1 eq 1 email like '%mystring%' else contact_email like '%mystring%' else id = 'mystring'
Also the if else construct in MSSQL Server can't be used inline. In this case you can use the CASE WHEN construct but judging by the dynamic nature of the full query you should replace your if then statements with CFIF CFELSE statements and send a complete query: > <cfif form.what eq 1> > select * from candidate where > <cfelse> > select * from advertiser where > </cfif> > <cfif form.by eq 1> > etc.... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201366 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54