Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Combine 2 consultas SELECT LEFT JOIN, união/declaração AS não funcionando


Acho que você escreveu os SELECTs no lugar errado.
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;