1

if ステートメントの近くでこの構文に問題があります。近くで mysql 構文をチェックし続けます

== 'purp1' and product_price==53, 13, 0) as ShipWeight  

これが私が達成しようとしていることです。何か案は?

select wp_cart66_order_items.order_id as Order_ID,
   wp_cart66_orders.trans_id as Order_Number,
   wp_cart66_orders.bill_first_name as Bill_First_Name,   
   wp_cart66_orders.bill_last_name as Bill_Last_Name,
   wp_cart66_orders.ship_first_name as Ship_First_Name,
   wp_cart66_orders.ship_last_name as Ship_Last_Name,
   wp_cart66_orders.ship_address as Ship_Address1,
   wp_cart66_orders.ship_address2 as Ship_Address2,
   wp_cart66_orders.ship_city as Ship_City,
   wp_cart66_orders.ship_state as Ship_State,
   wp_cart66_orders.ship_zip as Ship_zip,
   wp_cart66_order_items.item_number as Item_Number,
   wp_cart66_order_items.product_price as Price,
   wp_cart66_order_items.Description as OrderItemsDescription,
if(item_number == 'purp1' and product_price==53, 13, 0) as ShipWeight
from wp_cart66_orders 
inner join wp_cart66_order_items
    on wp_cart66_orders.id=wp_cart66_order_items.order_id 
where wp_cart66_orders.ordered_on between "2013-04-01 00:00:00" and "2013-04-02 23:59:59"
4

1 に答える 1

0

==ドキュメントを参照しているときに、mysql が をサポートしているかどうかがわかりません。=

if(item_number = 'purp1' and product_price=53, 13, 0) as ShipWeight

更新 1

使用するCASE()

CASE 
    WHEN item_number = 'marley1' and product_price='12.00' THEN 2
    WHEN item_number = 'samp1' and product_price='19.50' THEN 4
    ELSE 0
END ShipWeight
于 2013-04-09T15:57:31.027 に答える