Notes about things

A collection of my notes. Provided as is with no warranty of any kind expressed or implied.

Replacing partial strings in MySQL databases

I'm sure there's a better way but sometimes I need to replace a partial string in a database. For example replacing a domain name.

Be careful with this. Find/replace is awesome and if you're not careful it can really screw you up. With that in mind:

UPDATE DBNAME.TableName
SET DBNAME.TableName = REPLACE(DBNAME.TableName.FieldName,'OldString','NewString')
WHERE DBNAME.TableName.FieldName like '%OldString%';