Check live the Example http://sqlfiddle.com/#!9/9d3c4
We are basing the example on a table with varchar records
CREATE TABLE uno___
(
str varchar(255)
);
insert into uno VALUES ( 'anteprima/image/descriptions/555b2343cb43a-555b2343c94f3-wink_smile.gif');
insert into uno VALUES ( 'anteprima/image/descriptions/555b2343cb43a-dd3b2343c94f3-wink_smile.gif');
insert into uno VALUES ( 'anteprima/image/descriptions/555b2343cb43a-555b2343c94f3-wink_smiles.gif');
insert into uno VALUES ( 'anteprima/image/descriptions/555b2343cb43a-555b2343c94f3d-wink_smile.gif');
insert into uno VALUES ( 'anteprima/image/descriptions/555b2343cb43a-555b2343c9qdq4f3-wink_smile.gif');
We want to REPLACE 'anteprima/image/descriptions/' with 'image/catalog/descriptions/'
within each record.
UPDATE uno set str = replace(str, 'anteprima/image/descriptions/', 'image/catalog/descriptions/');
It's useful, for example, to move image paths of your products in magento, opencart, prestashop and so on.
sample (used for real) query that I used in opencart due to the missing images after a migration.
UPDATE oc_product_description SET
oc_product_description.description = replace(oc_product_description.description, 'anteprima/image/descriptions/', 'image/catalog/descriptions/');
Comments
Post a Comment