[SOLVED] mysql: nesting a 'concat' within a 'replace'

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

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

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

UPDATE table_name SET column2 = REPLACE (column2 , column1 , CONCAT( 'hoorah_', column1 ))
works for me...
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post 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
Post Reply