MySql - Way to update portion of a string?

后端 未结 4 1251
粉色の甜心
粉色の甜心 2020-11-29 20:52

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

4条回答
  •  误落风尘
    2020-11-29 21:25

    Use the LIKE operator to find the rows that you care about and update them using the REPLACE function.

    For example:

    UPDATE table_name SET field_name = REPLACE(field_name,'search','replace') WHERE field_name LIKE '%some_value%'
    

提交回复
热议问题