SQL LEFT JOIN Subquery Alias

后端 未结 2 1954
一个人的身影
一个人的身影 2020-12-23 02:51

I\'m running this SQL query:

SELECT wp_woocommerce_order_items.order_id As No_Commande
FROM  wp_woocommerce_order_items
LEFT JOIN 
    (
        SELECT meta_         


        
2条回答
  •  情歌与酒
    2020-12-23 03:25

    I recognize that the answer works and has been accepted but there is a much cleaner way to write that query. Tested on mysql and postgres.

    SELECT wpoi.order_id As No_Commande
    FROM  wp_woocommerce_order_items AS wpoi
    LEFT JOIN wp_postmeta AS wpp ON wpoi.order_id = wpp.post_id 
                                AND wpp.meta_key = '_shipping_first_name'
    WHERE  wpoi.order_id =2198 
    

提交回复
热议问题