Skip to main content
Inspiring
April 9, 2010
Répondu

Inserting a variable + string using select statement with cfquery

I'm trying to do an insert by a select statement where the insert for one of the fields needs to be a combination of a vaule retrieved from the select and concatenated with a string of text. Is this possible and if so what would the correct syntax be? Here is an example of what I'm trying but is not working.

<cfquery name="createnote" datasource="#application.datasource#">
        INSERT INTO gtbl_notes(notedate, strCustomerID, notetype, note, notecreatedby)
        SELECT "#currentdate#", strCustomerID, "misc", "#gtbl_people.email#  REMOVED DUE TO HARD BOUNCE", "Bounce Routine"
        FROM gtbl_people, gtbl_bounces
        WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2

</cfquery>

Any input would be greatly appreciated.

Ce sujet a été fermé aux réponses.
Meilleure réponse par Dan_Bracuk

Concatonation is possible with most if not all databases.  The syntax is software specific and you didn't specify yours.

2 commentaires

Inspiring
April 9, 2010

After posting this message I found what I was looking for. The concat function solved my issue:

concat(gtbl_people.email, " removed due to hard bounce")

Dan_BracukRéponse
Inspiring
April 9, 2010

Concatonation is possible with most if not all databases.  The syntax is software specific and you didn't specify yours.