gpt4 book ai didi

mysql - 获取查询错误的查询

转载 作者:行者123 更新时间:2023-12-01 00:46:46 25 4
gpt4 key购买 nike

我正在使用以下代码并想知道为什么我会收到“查询的查询”错误?

<cfquery name="findpercentage" datasource="#mydatasource#">

SELECT
Count(TableId_bi) AS Total_Events
,Sum(CASE WHEN 'OPEN' = Event_vch THEN 100 END) / Count(*) AS OPENS
,Sum(CASE WHEN 'BOUNCE' = Event_vch THEN 100 END) / Count(*) AS BOUNCE
,Sum(CASE WHEN 'DEFERRED' = Event_vch THEN 100 END) / Count(*) AS DEFERRED
,Sum(CASE WHEN 'DROPPED' = Event_vch THEN 100 END) / Count(*) AS DROPPED
,Sum(CASE WHEN 'DELIVERED' = Event_vch THEN 100 END) / Count(*) AS DELIVERED
,Sum(CASE WHEN 'PROCESSED' = Event_vch THEN 100 END) / Count(*) AS PROCESSED
,Sum(CASE WHEN 'SPAMREPORT' = Event_vch THEN 100 END) / Count(*) AS SPAMREPORT
FROM
mydatabase;


</cfquery>


<cfdump var="#findpercentage#">



<cfquery name = "piechartdisplay" dbtype = "query">

SELECT OPENS as Ecount, 'Open' as type
from findpercentage

UNION

SELECT BOUNCE as Ecount, 'Bounce' as type
from findpercentage

UNION

SELECT DEFERRED as Ecount, 'Deferred' as type
from findpercentage

UNION

SELECT DROPPED as Ecount, 'Dropped' as type
from findpercentage

UNION

SELECT DELIVERED as Ecount, 'Delivered' as type
from findpercentage

UNION

SELECT PROCESSED as Ecount, 'Processed' as type
from findpercentage

UNION


SELECT SPAMREPORT as Ecount, 'Spamreport' as type
from findpercentage



</cfquery>




<cfdump var="#piechartdisplay#">

查询的第一部分是在网页上转储属性,但是,“piechartdisplay”的第二次转储尝试生成查询或查询错误。错误描述如下:

Error Executing Database Query.

Query Of Queries syntax error.
Encountered "DEFERRED. Incorrect Select List, Incorrect select column,

The error occurred in C:\Path\myfile.cfm: line 39

37 :
38 :
39 : <cfquery name = "piechartdisplay" dbtype = "query">
40 :
41 : SELECT OPENS as Ecount, 'Open' as type
SQL SELECT OPENS as Ecount, 'Open' as type from findpercentage UNION SELECT BOUNCE as Ecount, 'Bounce' as type from findpercentage UNION SELECT DEFERRED as Ecount, 'Deferred' as type from findpercentage UNION SELECT DROPPED as Ecount, 'Dropped' as type from findpercentage UNION SELECT DELIVERED as Ecount, 'Delivered' as type from findpercentage UNION SELECT PROCESSED as Ecount, 'Processed' as type from findpercentage UNION SELECT SPAMREPORT as Ecount, 'Spamreport' as type from findpercentage

我必须像下面这样传递来自上面查询的数据(在它开始无错误地运行之后),这就是为什么我像上面那样写我的 QoQ:

<cfset dataItem =[
'#type#', '#Ecount#'
]>

请指出我这里哪里错了。

最佳答案

正如错误所暗示的,deferred 是一个保留字(“Reserved words in queries”)。在您的原始查询中将其别名化为其他内容,或尝试在 QoQ 中使用方括号将其转义。

关于mysql - 获取查询错误的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21226969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com