Link to home
Start Free TrialLog in
Avatar of andw928
andw928

asked on

Not escaping a mysql variable within a string.

I have the following query:

SELECT @test := 'hello', CONCAT('Message: @test', column_name)

The problem is that this displays "Message: @test", instead I want to display the variable @test that I set right before it, although, I do NOT want to put it seperately like this:

CONCAT('Message:', @test, column_name)

Is there anyway to evaluate a variable enrapped inside quotes without seperating it from the rest of the string so that it shows its value?
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

No.  Why don't you want to list it separately?
Avatar of kupra1
kupra1

It is not doing what it should because how it can distinguish whether you want a variable substitution or the string in itself (i.e. @test in this case). By putting it inside the quotes ' ', you are making it a string.
Avatar of andw928

ASKER

snoyes, because I am passing a coldfusion function which can't be seperated.
kupra1, you did not read my entire post.

Does anybody else have a possible solution?
ASKER CERTIFIED SOLUTION
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andw928

ASKER

You are a genius my friend, it works well, thank you!