I have a question regarding some SQL queries in WordPress. The object is getting the following information from multiple tables and their columns.
I need: Ordered Time | Date and Time | Name | Email | Department | Total Orders | Amount
I've scoped out the following as a visual aid for myself:
wp_postmeta
contains:
- Department as = billing_field_267
- Email as = billing_email
- First Name = _billing_first_name
- Last Name = _billing_last_name
wp_wc_order_stats
contains:
- Date and Time = date_created
- Ordered Time = billing_field_739
- Amount = ??
- Total Orders = ??
The billing fields are meta_keys so I just need their values.
I've tried the following SQL Statement to get what I need:
SELECT
user.meta_key, user.meta_value
FROM
wp_postmeta AS user, wp_wc_order_stats as order
WHERE
user.meta_key='billing_field_267', user.meta_key='billing_email', user.meta_key='_billing_first_name', user.meta_key='_billing_last_name', user.meta_key='billing_field_739'
AND
order.date_created
It doesn't seem to be working as needed some help in the right direct would be apprecaited.