MySql - Way to update portion of a string?

Viewed 86261

I'm looking for a way to update just a portion of a string via MySQL query.

For example, if I have 10 records all containing 'string' as part of the field value (i.e., 'something/string', 'something/stringlookhere', 'something/string/etcetera', is there a way to change 'string' to 'anothervalue' for each row via one query, so that the result is 'something/anothervalue', 'something/anothervaluelookhere', 'something/string/etcetera', is there a way to change 'anothervalue'

4 Answers

Does something like this work in any way?

update table_name
set column_name = replace(column_name, 'string%', 'string') 
where column_name like '%string%'
Related