Return to Snippet

Revision: 65884
at February 4, 2014 21:22 by apphp-snippets


Initial Code
-- 1st example
UPDATE files SET filepath = REPLACE(filepath,'path/to/search','path/to/replace');
 
-- 2nd example
UPDATE customers SET address = REPLACE(address,'_CODE_',postcode);

Initial URL
http://www.apphp.com/index.php?snippet=mysql-find-and-replace

Initial Description
MySQL has a handy and simple string function REPLACE() that allows table data with the matching string to be replaced by new string. This is useful if there is need to search and replace a text string which affects many records or rows, such as change of address, company name, URL or spelling mistake.

Initial Title
Find and Replace with MySQL

Initial Tags
mysql, replace, find

Initial Language
MySQL