【问题标题】:Why doesn't Lucee consider column alias name in QoQ为什么 Lucee 不考虑 QoQ 中的列别名
【发布时间】:2016-11-04 08:39:07
【问题描述】:

我在本地 CF 和 Lucee 服务器中比较了以下查询。 ColdFusion 服务器引发 QoQ 运行时错误。但是,当我在 Lucee 中执行相同的查询时,它会返回所需的查询结果。

<cfquery name="getusers" datasource="myDSN">
    SELECT 
        UC.UserContactName, U.UserID 
    FROM Users U 
        INNER JOIN UserContacts UC ON U.UserID = UC.UserID 
    WHERE U.UserID in (99,52,41,76,15) 
</cfquery>

<cfquery name="getContactName" dbtype="query">
    SELECT UserContactName FROM getusers 
    WHERE U.UserID  = <cfqueryparam value="76" cfsqltype="cf_sql_integer">
</cfquery>

<cfdump var="#getContactName#" />

CF服务器在上面的代码中抛出这个错误,因为它考虑了别名:

所选列引用 U.UserID 与 FROM 表列表。

但是,Lucee 服务器不考虑别名,运行上面没有错误。有谁知道为什么 Lucee 服务器不考虑 QoQ 列别名?请分享您对此的想法或建议。

【问题讨论】:

    标签: coldfusion coldfusion-10 lucee qoq


    【解决方案1】:

    getusers 查询结果在列中:

    UserContactName | UserID

    getusers 上的 QoQ 不再存储任何与表相关的信息。如果您引用 U(如 U.UserID),ACF 预计 QoQ 中的(新)引用能够解决 U 的含义。

    另一方面,Lucee 存储这些信息并可以使用别名来解析它。 You can check the source code how it parses the QoQ statement.

    无论 Lucee 的功能如何,我都建议在 QoQ 语句中删除以前的别名。当您的查询转储甚至没有提示您存储的别名时,请考虑调试 QoQ 语句。

    【讨论】:

      猜你喜欢
      • 2018-05-14
      • 1970-01-01
      • 2017-04-26
      • 2011-01-24
      • 1970-01-01
      • 2013-04-25
      • 2013-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多