我有这个SQL查询:
SELECT *, GROUP_CONCAT(inter_postmeta.meta_value SEPARATOR '|') AS all_data
FROM inter_woocommerce_order_itemmeta
LEFT JOIN inter_woocommerce_order_items ON inter_woocommerce_order_itemmeta.order_item_id = inter_woocommerce_order_items.order_item_id
LEFT JOIN inter_posts ON inter_posts.ID = inter_woocommerce_order_items.order_id
LEFT JOIN inter_postmeta ON (inter_postmeta.post_id = inter_woocommerce_order_items.order_id
AND (inter_postmeta.meta_key = '_shipping_first_name'
OR inter_postmeta.meta_key = '_shipping_last_name'
OR inter_postmeta.meta_key = '_shipping_postcode'
OR inter_postmeta.meta_key = '_shipping_city'
OR inter_postmeta.meta_key = '_shipping_address_1'
OR inter_postmeta.meta_key = '_shipping_address_2'))
WHERE inter_woocommerce_order_itemmeta.meta_key = '_fc_data' AND inter_woocommerce_order_itemmeta.meta_value LIKE '%2017-2-1'
GROUP BY inter_woocommerce_order_itemmeta.order_item_id
如果我在PhpMyAdmin上执行它,它将返回我需要的内容:
但是当我使用$ wpdb-> get_results运行完全相同的查询时,meta_key和mea_value字段会有所不同。
如何使用$ wpdb获得相同的结果?并且完全相同的查询如何返回不同的结果?