Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
385 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

SELECT (x.event_code || event_name) fred

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...