下面是我试图执行的查询,它会引发1048 Column 'sub_order_id' cannot be null
错误。所以我检查了表格,并且两个order_products_boxes
表格orders_products
似乎都有数据sub_order_id='22861-1R'
,所以知道为什么我仍然收到错误吗?
SELECT Upper(Ifnull(op.supplier_payment_method, '')) AS
Payment_Method,
op.supplier_payment_date AS
Payment_Date,
Date_format(Ifnull(op.supplier_payment_date, op.ship_date), '%M %Y') AS
Payment_Month,
'B&H' AS
Farm,
op.sub_order_id AS
Order_num,
Date_format(op.ship_date, '%b-%d-%Y') AS
Ship_Date,
op.farm_credit AS
Farm_Credit,
op.credit_memo AS
Credit_Memo,
op.credit_description AS
Credit_Description,
opb.boxes AS
Box_Type,
Concat('$', Format(op.box_charge, 2)) AS
Box_Charge,
op.invoice_num AS
Invoice_num,
Concat('$', Format(op.invoice_amt, 2)) AS
Invoice_Amt,
Concat('$', Format(op.total_invoice_amt, 2)) AS
Total_Invoice_Amt,
Concat(op.um_qty, ' ', op.um_type) AS
St_Bu_Qty,
op.po_product_name AS
Invoice_desc,
Concat('$', Format(( op.price_um * op.um_qty ), 2)) AS
Cost_product_cms,
op.supplier_invoice_note AS
Supplier_Invoice_Notes,
Concat('$', Format(op.cms_invoice_cost, 2)) AS
CMS_Invoice_diff,
Concat('$', Format(op.total_farm_cost, 2)) AS
Farm_Cost
FROM orders_products op
LEFT JOIN (SELECT sub_order_id,
Group_concat(Concat(box_type_qty, ' ', bo.box_option_name)
SEPARATOR
', ') AS
boxes
FROM order_products_boxes opb
INNER JOIN box_options bo
ON bo.id = opb.box_type_id
WHERE opb.sub_order_id = '22861-1R') opb
ON opb.sub_order_id = op.sub_order_id
WHERE op.sub_order_id = '22861-1R'
ORDER BY op.ship_date DESC