sql >> Databasteknik >  >> RDS >> Mysql

Kombinera 2 SELECT LEFT JOIN-förfrågningar, union/deklarera AS fungerar inte

Jag tror att du skrev SELECT på fel ställe.

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;


  1. bind_param svårigheter

  2. körtidsfel:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver

  3. Oracle:Beräkna tidsskillnaden i TT:MM:SS mellan 2 datum

  4. Kombinera två kolumner i SQL for WHERE-satsen