我需要在安装了WooCommerce的情况下查询WordPress数据库,以查找在过去5天内完成订单的所有用户。我需要运行原始的MySql - 我没有选择使用WP或WooCom API。
到目前为止我已经
了SELECT wp_users.user_login as "users::username",
wp_users.user_email as "users::email"
FROM wp_users
WHERE (UNIX_TIMESTAMP(STR_TO_DATE(date_format(DATE_SUB(NOW(),
INTERVAL 5 DAY),
'%d-%m-%Y'),
'%d-%m-%Y')) <
UNIX_TIMESTAMP(STR_TO_DATE(date_format((SELECT wp_posts.post_date
FROM wp_posts
JOIN wp_postmeta
ON wp_postmeta.post_id =
wp_posts.ID
AND wp_postmeta.meta_key =
'_customer_id'
WHERE wp_posts.post_type =
'shop_order'
AND wp_postmeta.meta_value =
wp_users.ID
ORDER BY wp_posts.post_date DESC LIMIT 1),
'%d-%m-%Y'),
'%d-%m-%Y')));
它返回0结果,应该有2.显然我的查询有些不对劲。有什么想法吗?
答案 0 :(得分:0)
_customer_id
应为_customer_user