title: How to get ONLY COMPLETED orders from woocommerce using SQL
body: <p>I am getting product order info from various tables. Now I want to get all this info also on the basis of Completed order. i.e order_status should be 'Completed'. </p>
  
  <p>Here is my SQL </p>
  
  <pre><code> SELECT distinct  posts.ID
   FROM   `wp_posts` AS posts,
          `wp_woocommerce_order_items` AS orderitems,
          `wp_woocommerce_order_itemmeta` AS orderitemsmeta, 
          `wp_term_relationships` AS postrel, 
          `wp_terms` AS postterms 
   WHERE    ( orderitemsmeta.order_item_id = orderitems.order_item_id ) 
   AND    ( orderitems.order_id = posts.ID )
   AND    ( postrel.object_id = orderitemsmeta.meta_value )
   AND    ( postrel.term_taxonomy_id &lt;&gt; 4 )
   AND    ( postterms.term_id = postrel.term_taxonomy_id )
   AND    ( posts.post_type = 'shop_order' )  
   AND    ( post_status != 'trash' ) 
   AND    ( post_date &gt; '2015-03-16')
   **//AND (order_status=completed)** //something like this
   ORDER  BY posts.post_date DESC";
  </code></pre>
  
  <p>How to do this? </p>
  
  <p>Any help will be appricaited. Thanks</p>