Running the exact same SQL query in PMA and WordPr

2019-09-19 06:06发布

I have this SQL Query:

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

If I execute it on PhpMyAdmin it returns what I need:

PhpMyAdmin

But when I run the exact same query using $wpdb->get_results, the meta_key and mea_value fields differ.

WPDB

How can I get the same results using $wpdb? Annd how is it possible that the exact same query return different results?

0条回答
登录 后发表回答