Get woocommerce orders for list users

by GAV   Last Updated January 13, 2018 16:08 PM

I cannot see how to join to woocommerce orders for users. The following will enable me to get users meta data which I need, but also need to see their last order and details from woocommerce. Seems quick tricky to join order details, as I can't see what to use to make a join, thanks?

SELECT, t1.user_email,
MAX(CASE WHEN t2.meta_key = 'first name' THEN meta_value END) AS first 
MAX(CASE WHEN t2.meta_key = 'last_name' THEN meta_value END) AS 
FROM wp_users AS t1 
INNER JOIN wp_usermeta AS t2 ON = t2.user_id
GROUP BY, t1.user_email;
Tags : woocommerce sql

Related Questions

How can add and preview product Frontend

Updated March 26, 2015 12:02 PM

How to add "Reply-to" in Woocommerce

Updated April 04, 2015 15:03 PM

WooCommerce epdq gateway Change order status

Updated April 06, 2015 19:03 PM