update part of a string in mysql 1

update part of a string in mysql

UPDATE table
SET field = REPLACE(field, 'string', 'anothervalue')
WHERE field LIKE '%string%';

Here is what the above code is Doing:
1. It’s selecting the table you want to update.
2. It’s selecting the field you want to update.
3. It’s replacing the string you want to replace.
4. It’s replacing the string with the string you want to replace it with.
5. It’s selecting the field you want to search for the string.
6. It’s searching for the string.

Similar Posts