I've got a temporary table full of my drop shippers' on-hand inventory which I'd like to use in order to update my woocommerce website. I'm using the supplier's SKU as a key , but woocommerce has this buried so I have to use a subquery on the join.
update yra_postmeta
join supplier_stock on
(select meta_value from yra_postmeta where meta_key='_supplier_sku') = supplier_stock.supplier_sku
set yra_postmeta.meta_value = CASE WHEN supplier_stock.stock < 1 AND yra_postmeta.meta_key = '_stock_status' THEN 'outofstock'
WHEN supplier_stock.stock >=1 AND yra_postmeta.meta_key = '_stock_status' THEN 'instock'
end
I'm getting "error Code: 1093. You can't specify target table 'yra_postmeta' for update in FROM clause" which seems to be quite common, and there seem to be some solutions out in the wild, but I can't seem to make any of them work for this particular query? Any Ideas how to make this work?
