Find & Replace

The string REPLACE() function can be used to find and replace a text string within a table.



REPLACE(text_string, from_string, to_string)


Which can be used with the UPDATE command as follows:

UPDATE TABLE_NAME SET FIELD_NAME = REPLACE(FIELD_NAME, ‘find this string’, ‘replace found string with this string)


e.g. UPDATE wp_8_posts SET post_content = REPLACE(post_content, 'advcpp', 'intcpp')

this example will UPDATE all records in the wp_8_posts table where the post_content field contains advcpp and replace it with intcpp.



Another example:


SELECT REPLACE(‘’, ‘w’, ‘X’)


Which would result in ‘’

Leave a Reply