SQL query to replace part of field in PHPMyAdmin

  • Hi,

    I have a table called 'wp_postmeta' (WordPress) which contains a column called 'meta_value'. A typical field in this column looks like this:

    a:22:{s:12:"productimage";s:104:"http://www.disobeyclothing.com/wp-content/themes/eCommerce3/images/tshirts/SurveillanceSociety-Black.png";s:13:"productimage1";s:104:"http://www.disobeyclothing.com/wp-content/themes/eCommerce3/images/tshirts/SurveillanceSociety-White.png";s:13:"productimage2";s:0:"";s:13:"productimage3";s:0:"";s:13:"productimage4";s:0:"";s:13:"productimage5";s:0:"";s:13:"productimage6";s:0:"";s:5:"price";s:5:"10.50";s:12:"spPrdLstDate";s:0:"";s:12:"specialprice";s:4:"0.00";s:6:"weight";s:3:"250";s:9:"istaxable";s:0:"";s:4:"size";s:12:"S,M,L,XL,XXL";s:5:"color";s:11:"Black,White";s:10:"size_stock";s:5:",,,,,";s:11:"color_stock";s:2:",,";s:19:"is_check_outofstock";s:0:"";s:9:"initstock";s:0:"";s:8:"minstock";s:1:"0";s:11:"isshowstock";s:0:"";s:14:"affiliate_link";s:0:"";s:8:"posttype";s:7:"product";}

    I'd like to replace all instances of 'http://www.disobeyclothing.com' with 'http://www.projectdisobey.com/disobeyclothing/uk'.

    I've tried to run the following query but each time I run it, it wipes all data in the field:

    UPDATE wp_postmeta set meta_value=replace(meta_value, 'http://www.disobeyclothing.com', 'http://www.projectdisobey.com/disobeyclothing/uk')

    I've also tried this query, but it has the same effect:

    UPDATE wp_postmeta

    SET meta_value = replace(LTRIM(RTRIM(meta_value)), 'http://www.disobeyclothing.com', 'http://www.projectdisobey.com/disobeyclothing/uk');

    Any suggestions as to what I might be doing wrong (and how to do it right)?

    Thanks!

  • Upon further inspectation I can that the query worked just fine, and the field data has been replaced appropriately, but for some reason, after running the query all the product pages on my eCommerce site appear blank, as if the data has been wiped.

    Any idea what this could be? I'm a bit of a Newbie when it comes to SQL...

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply