How to write a SQL to replace strings in a column in a MySQL database table?

Posted on In QA

How to replace strings in a column in a MySQL database table? For example, I would like to replace http://www.systutorials.com with https://www.systutorials.com in a content column of a table post.

You may use a SQL statement as follows.

update post
set content = replace(content, 'http://www.systutorials.com', 'https://www.systutorials.com')
where content like '%http://www.systutorials.com%'

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *