I’m trying to convert select command that I can retrieve the variables set to products to a replace / update command. Due to update to woocommerce 3.0 + smart manager plugin messed up my product attributes and variables. 🙁

With this command Im able to retrieve my product attribures based on part of title:

SELECT * FROM m6el_postmeta,m6el_posts 
WHERE m6el_postmeta.post_id = m6el_posts.ID and post_title LIKE '%suuline%' and meta_value like "135-cm%"

And I get the results displayed just fine, but I have been unable to cook up a working statement to update or replace the broken attributes:

select meta_key, replace (meta_value,'135-cm','135-cm-2') FROM m6el_postmeta AS postmeta
LEFT JOIN m6el_posts AS products ON ( products.ID = postmeta.post_id )
WHERE postmeta.meta_key LIKE 'attribute_pa_suurus' and post_title LIKE '%suuline%' and meta_value like '135-cm%'

The statement runs fine via phpMyAdmin, but does not actually perform any replacement eg. meta_
(Showing rows 0 – 24 (4029 total, Query took 0.0081 seconds.)

What AM I doing wrong with the update / replace ? As there are multiple products with different attributes so I cannot also use just a simplified update (just replace 135-cm with 135-cm-2 in all fields of ‘meta_value’ in postmeta table)

Read more here: Update product attribures in woocommerce using SQL


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: