MySQL find/replace

Posted by Colin A. Bartlett Thu, 10 May 2007 20:35:00 GMT

NEAT!

I just discovered (thanks Google!) that you can do find/replace within strings inside a MySQL table. In this case, I had to push a website live that contained product descriptions in which the client had referenced the development site URL. So:

update products set description = replace(description, 'beta.', 'www.');

Worked like a charm. I was about to do a mysqldump and do something with sed and grep and then have to re-import the table. But this worked great.

Comments

Leave a response

Comments