REPLACE: Find and Replace Text in MySQL Database Using SQL

The syntax of REPLACE is REPLACE(text_string, from_string, to_string)

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);

update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’)

Another example:


SELECT REPLACE(‘www.mysql.com’, ‘w’, ‘Ww’);

Above statement will return ‘WwWwWw.mysql.com’ as result.

Comments

comments

Recent Posts