Find and Replace with MySQL

/ Published in: MySQL
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. -- 1st example
  2. UPDATE files SET filepath = REPLACE(filepath,'path/to/search','path/to/replace');
  4. -- 2nd example
  5. UPDATE customers SET address = REPLACE(address,'_CODE_',postcode);


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.