Update a column value, replacing part of a string

say  we have entries like  http://domain.com/v1/xyz/* in url column of my table “links” where * stand for different-2 values. I want to replace domain.com => 127.0.0.1  in all  my url entires.

Asked on September 15, 2020 in Mysql.
Add Comment
1 Answer(s)
update [table_name] set [field_name] = 
replace([field_name],'[string_to_find]','[string_to_replace]');

so in your case say,

update links set url = replace(url, 'domain.com', '127.0.0.1'); 

first try for 1 row by using where condition. If all fine .. run without where condition..
Answered on September 15, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.