title: Update all product variation sale prices of a Woocommerce variable product
body: <p>I have about 10 products with close to 200 variations each. I need to update the sale prices for a specific product, including all its variations.</p>
  
  <p>The problem is:</p>
  
  <p>All variations have different prices.
  No sale prices have been entered - all sale price input boxes are empty.</p>
  
  <p>I need either a SQL solution to run and update all sale prices for the specific product by taking the regular price and deducting 350 from it, OR</p>
  
  <p>Any other way that i am not aware of at this stage as I have tried many solutions including Woocommerce built in solution "set sale price", again which does not work as the prices are not the same.</p>
  
  <pre><code>SELECT * FROM `wp_postmeta` WHERE post_id = "1097"
  UPDATE `meta_id` = (SELECT * FROM `wp_postmeta` WHERE `meta_value` = _regular_price) - 350 WHERE `meta_key` = _sale_price
  </code></pre>
  
  <p><em>Edited query as research on Stackoverflow suggests that wp_postmeta table holds values for products and wp_posts table holds product id's.</em></p>
  
  <p>Here is a screen shot of the problem I face:</p>
  
  <p><a href="https://i.stack.imgur.com/q80Xd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q80Xd.png" alt=")"></a></p>
  
  <p>You will see the meta_id is different and the post_id is the same, this is because in WordPress the post_id is the product, in this case on with many variations of itself, and meta_id is the _sale_price part I need to update FOR EACH VARIATION</p>
  
  <p>I hope this makes sense!</p>