下面是我試圖執行的查詢,並且拋出了1048 Column 'sub_order_id' cannot be null
錯誤。所以我查了表,order_products_boxes
和orders_products
表似乎有數據對sub_order_id='22861-1R'
,所以任何想法,爲什麼我仍然得到錯誤?mysql錯誤,列爲空
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
是INSERT語句的一部分嗎? –
不,這只是一個選擇查詢 – Bluemagica
問題....如果您從查詢中刪除該字段....查詢的工作原理是如果?? – Hackerman