我正在运行同一应用程序的两个实例,但只有一个实例在尝试显示未标记的图像时出现错误。
日志显示:
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 '' at line 3 The specific sequence of files included or processed is: [obscured]...images_archive.cfm, line: 24
该文件的第 24 行是:
WHERE <cfloop query="unlabeledTags">tagID <> #ID#<cfif #currentRow# NEQ #recordCount#> AND </cfif></cfloop>
非常感谢任何帮助
最佳答案
就像 Leigh 所说的那样,您的问题可能是空查询集,但为了稍微清理一下您的代码,我建议您像这样编写 SQL。
WHERE tagID NOT IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#ValueList(unlabeledTags.ID)#" list="true">)
或者你也可以这样写
WHERE 1 = 1
<cfloop query="unlabeledTags">
AND tagID <> <cfqueryparam cfsqltype="cf_sql_integer" value="#unlabeledTags.ID#">
</cfloop>
仅当查询有记录数时才允许运行查询。
关于mysql - Coldfusion sql 错误仅发生在应用程序的一个实例上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15559114/