String Replace in MySQL - diet, aesthetic surgery, travel, tour, hotels wellness, weight loss and fat burning tips

I found out about this functionality just a few months ago. I can’t believe I went for years writing little scripts to pull the data out, manipulate it with string functions, and then post it back in.

Admittedly this is only really useful for simple changes. Most of the time I’ve had to make more detailed changes.

But nevertheless it is useful. In my case, most often when an update to a database doesn’t go quite as expected, leaving odd or rogue results – resulting in whole or part of a string needing to be replaced, or additional text inserted (same thing). This sure beats editing records by hand or knocking up little update scripts.

The usage is similar in a way to the PHP string replace function:

replace(in_Field, old_string, new_string)

An example:

UPDATE myTable
SET myField =
REPLACE (myField, 'oldString', 'newString')
WHERE ...
And you simply change your WHERE clause to suit your own conditions. Or leave it out altogether.