问题
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