Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Kombinieren Sie 2 SELECT LEFT JOIN-Abfragen, Union/Deklaration von AS funktioniert nicht

Ich glaube, Sie haben die SELECTs an der falschen Stelle geschrieben.

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;