Sahanaa01 Sahanaa01 - 7 months ago 7
SQL Question

update records of a column in mysql by adding a value to middle of the string

I have a column called 'url' in 'table' whose records are in the pattern 'http://example.com/value/372954412/'.

I want to update these to 'https://www.example.com/value/372954412/'. The size of the table is huge. How do I go about this?

Answer

The function to replace a string with another is REPLACE:

update my_table
set url = replace(url, 'http://', 'https://www.');
Comments