Skip to main content
Inspiring
April 9, 2010
Answered

Inserting a variable + string using select statement with cfquery

  • April 9, 2010
  • 2 replies
  • 661 views

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.

This topic has been closed for replies.
Correct answer Dan_Bracuk

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

2 replies

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_BracukCorrect answer
Inspiring
April 9, 2010

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