Inconsistent Q of Q Behaviour

一世执手 提交于 2019-12-13 04:38:37

问题


Using ColdFusion Server Enterprise 9,0,1,274733.

Has anyone seen this before? The following code executes without error.

<cfquery name="x" datasource="dw">
select event_code, event_name
from event
</cfquery>

<cfquery name="y" dbtype="query">
select event_code || event_name fred
, event_code
from x
</cfquery>

Two things to notice are that I declared an alias without using the keyword "as", and I used || to concatenate strings. However, if I qualify the first event code, like this:

<cfquery name="y" dbtype="query">
select x.event_code || event_name fred
, event_code
from x
</cfquery>

I get

Query Of Queries syntax error.

Encountered ". Incorrect Select List, Incorrect select column, x.event_code cannot be followed by '||'

There is a similar error if I attempt to declare an alias without the keyword "as".

For the task at hand, I can figure out what to do, but I'm curious if the same thing happens to those of you on Version 10?

Edit starts here

After reading the comments, I tried parentheses. This runs without error.

<cfquery name="y" dbtype="query">
select (x.event_code || event_name) fred
, event_code
from x
</cfquery>

回答1:


You have to wrap your statement in () for it to work correctly

SELECT (x.event_code || event_name) fred


来源:https://stackoverflow.com/questions/21786926/inconsistent-q-of-q-behaviour

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!