通过SQL查询获取具有元值的WooCommerce订单

时间:2018-08-23 11:28:13

标签: mysql sql woocommerce

我正在制作一个插件,以出售具有中继价值的Menus(内部带有餐具的复合产品)。我想出售所有带有meta键wcmenu_day和值的产品。我还有一个复合的产品类型。我做了一个SQL,但不正确。某事不起作用...

SELECT DISTINCT pm.post_id
FROM wp_postmeta as pm
INNER JOIN wp_woocommerce_order_items as woi ON pm.post_id = woi.order_id
INNER JOIN wp_woocommerce_order_itemmeta as woim ON woi.order_item_id = woim.order_item_id
INNER JOIN wp_term_relationships as tr ON woim.meta_value = tr.object_id
INNER JOIN wp_term_taxonomy as tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
INNER JOIN wp_terms as t ON tt.term_id = t.term_id
WHERE pm.meta_key LIKE 'wcmenu_day'
AND pm.meta_value LIKE '2018-08-22'
AND woi.order_item_type LIKE 'line_item'
AND woim.meta_key LIKE '_product_id'
AND tt.taxonomy LIKE 'product_type'
AND t.slug LIKE 'composite'
ORDER BY pm.meta_value DESC

你能帮忙吗?

0 个答案:

没有答案