Page 1 of 1

mysql: nesting a 'concat' within a 'replace'

Posted: Fri Oct 08, 2004 12:33 pm
by dsdsdsdsd
hello;

I have the_table:
col_1 , col_2
-------------------------
aaa , aaa_do aaa_dat

the query that I am using:"update the_table set col_2=replace(col_2,col_1,concat('hoorah_' , col_1) ) "

I want
col_1 , col_2
-------------------------
aaa , hoorah_aaa_do hoorah_aaa_dat

however the query does not successfully stick the 'hoorah_' in front of the aaa_dat; instead I get this:
col_1 , col_2
-------------------------
aaa , hoorah_aaa_do aaa_dat


any thoughts?

thanks
Shannon Burnett
Asheville NC USA

Posted: Fri Oct 08, 2004 2:51 pm
by feyd

Code: Select all

UPDATE table_name SET column2 = REPLACE (column2 , column1 , CONCAT( 'hoorah_', column1 ))
works for me...

Posted: Fri Oct 08, 2004 3:00 pm
by dsdsdsdsd
feyd, thanks for responding;

yeah it works; I failed to upload the correct .php file to my server; so I was getting an error because I had an older script running;

thanks
Shannon Burnett
Asheville NC USA