2017-02-16 186 views

回答

6

您可以使用下面的查詢獲取的結果:

$results = $wpdb->get_results( 
    'SELECT wpp.order_item_id as OrderPrimaryID,wpp.order_id as OrderID, 
      wpm.meta_value as OrderProductId,wpsot.post_author as OrderPostAuthor, 
      wpu.ID as OrderUserID,wpu.user_email as OrderUserEmail FROM wp_woocommerce_order_items as wpp 
    INNER JOIN wp_woocommerce_order_itemmeta as wpm ON wpp.order_item_id=wpm.order_item_id 
    INNER JOIN wp_posts wpsot ON wpp.order_id=wpsot.ID 
    INNER JOIN wp_postmeta wppostmeta ON wpp.order_id=wppostmeta.post_id 
    INNER JOIN wp_users wpu ON wppostmeta.meta_value=wpu.ID 
    WHERE wpm.meta_key="_product_id" AND wppostmeta.meta_key="_customer_user"', 
    OBJECT 
); 
print_r($results); 

希望它能幫助。

相關問題