title: How to delete woocommerce products that belongs to specific category from the database
body: <p>I need a MySql query statement to delete all woocommerce products that belong to a category or do not belong to another, similar to this:</p>
  <pre><code>DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID
  FROM wp_posts
  LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
  LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
  WHERE wp_term_taxonomy.term_id NOT IN (29,31,32,33,34) AND post_type IN ('product','product_variation')
  GROUP BY wp_posts.ID);
  </code></pre>
  <p><strong>And I am dealing with a large amount of data, more than 100,000 products.</strong></p>