查询查询语法错误

时间:2014-03-14 18:44:13

标签: sql sql-server coldfusion coldfusion-10 qoq

我必须使用我的F / W1应用程序中的查询查询从查询​​中获取记录。我在coldfusion 10中运行它。我的查询如下,

<cfquery name="qryFormData" dbtype="Query">
      Select * from qryFormfields where language = 'ENG'
</cfquery>

我收到此错误

 ERROR!

An error occurred!
Action: locations.default
Error: Error Executing Database Query.
Type: Database
Details:
Query Of Queries syntax error.
Encountered "language. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,

我做错了什么?任何帮助将不胜感激。

我的查询非常简单如下

<cfquery name="qryFormfields" datasource="#variables.dsn#">
    SELECT cf.CustomFieldID, cfl.label,cfl.language,cf.Type FROM CustomFields cf 
    INNER JOIN CustomFieldLabels cfl ON cfl.CustomFieldID = cf.CustomFieldID
    AND Entity = <cfqueryparam  value="#arguments.tablename#" cfsqltype="cf_sql_varchar">
    WHERE Language = <cfqueryparam  value="#SupportedLangID.prefix#" cfsqltype="cf_sql_varchar">
    AND SiteID = <cfqueryparam  value="#arguments.SiteID#" cfsqltype="cf_sql_varchar">
</cfquery>

1 个答案:

答案 0 :(得分:7)

LANGUAGE是查询查询中的保留字。请参阅此处的文档:Query of Queries user guide: Escaping reserved keywords

因此,您需要在原始查询中为该列添加别名(或根据文档使用方括号将其转义)。