Looping over query variables
Posted on 2007-10-05
I'm trying to run a search against MS SQL Database and I am getting an error that seams odd to me and I am not sure why. Here is the error on CF7
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'AND'.
Here is the SQL:
<cfloop list="#searchword#" index="thisword" delimiters=" ">
AND (Keywords LIKE '%#thisword#%' OR Description LIKE '%#thisword#%' OR Title LIKE '%#thisword#%')
I am running a similar query on one of my access databases and it words, so I am assuming it's something unique to MS SQL.
It may or may not be worth mentioning that I will be adding some additional logic with a few more AND statements after this but those havent been writen yet. I am just trying to get the basic script working at this point.