Find and Replace with MySQL

If you’re just trying to find a replace a string in a MySQL table, you don’t need to write a script to do it. You can simply use the following syntax with MySQL (e.g. phpMyAdmin, MySQL shell access)

UPDATE TABLENAME SET COLUMNNAME = replace(COLUMNNAME,”FINDWHAT”,”REPLACEWITHWHAT”);Note that this method is case-sensitive. This is a great timesaver over doing it with a scripting language such as PHP. With PHP, you’d have to write a script to select the row, do the replacement, and update the table.

Leave a Reply

You must be logged in to post a comment.