avatar
replace part of string in single or multiple records MySQL

Assume we have a table named `urls` with a column named `itemprop_image`. Write an UPDATE statement to replace all occurrences of 'http://flagtickgroup.com' with 'https://www.flagtick.com' in the `itemprop_image` column for all records.

+---------------------+                  +---------------------+
|      fla_urls       |                  |      fla_urls       |
|---------------------|     UPDATE       |---------------------|
| itemprop_image      |  --------------> | itemprop_image      |
| 'https://flag...    |                  | 'https://www....    |
| 'https://flag...    |                  | 'https://www....    |
| 'https://flag...    |                  | 'https://www....    |
+---------------------+                  +---------------------+

Next, leverage the REPLACE function in SQL to perform this string manipulation.

UPDATE urls
SET itemprop_image = REPLACE(itemprop_image, 'https://flagtickgroup.com', 'https://www.flagtick.com');


24
You need to login to do this manipulation!