Mysql
 sql >> Base de données >  >> RDS >> Mysql

Combinez 2 requêtes SELECT LEFT JOIN, union/déclaration AS ne fonctionne pas

Je pense que vous avez écrit les SELECT au mauvais endroit.

SELECT (
  SELECT meta_value as product_id
  FROM ctc_woocommerce_order_itemmeta
  LEFT JOIN ctc_woocommerce_order_items ON ctc_woocommerce_order_itemmeta.order_item_id = ctc_woocommerce_order_items.order_item_id
  WHERE meta_key = '_product_id'
  AND order_id = 3988
) as product_id,
(
  SELECT meta_value as variation_id
  FROM ctc_woocommerce_order_itemmeta
  LEFT JOIN ctc_woocommerce_order_items ON ctc_woocommerce_order_itemmeta.order_item_id = ctc_woocommerce_order_items.order_item_id
  WHERE meta_key = '_variation_id'
  AND order_id = 3988
) as variation_id;