CFset string concatenation (of query results)
11,782
Solution 1
If you really need an additional variable, ColdFusion's concatenation operator is &
<cfset teacherName = Firstname &" "& Lastname>
Though for simple output, no extra variable is needed. Just output the column values:
<cfoutput query="getName">
#Firstname# #Lastname# <br>
</cfoutput>
Solution 2
try using <cfset teacherName= Firstname & " " & Lastname>
Solution 3
As an alternative to using the ColdFusion &
or &=
string operators, you can also do the following:
<cfoutput query="getName">
<cfset myName="#Firstname# #Lastname#">
<p>#myName#</p>
</cfoutput>
Related videos on Youtube
Author by
redconservatory
Updated on June 04, 2022Comments
-
redconservatory almost 2 years
Is it possible to set a ColdFusion variable to a concatenated string?
<cfoutput query="getName"> <cfset myName=#Firstname# #Lastname#> </cfoutput>
Doesn't seem to work, nor does
<cfoutput query="getName"> <cfset teacherName=#Firstname# + #Lastname#> </cfoutput>
-
Leigh over 12 yearsEdited to remove extraneous pound signs