我正在處理連接多個表的查詢。這裏是代碼。 查詢工作正常,直到我添加第三行SUM(SaleItems_T.qtymajor)AS銷售。我收到一條錯誤消息,其中說 「字段列表」中的未知列'SaleItems_T.qtymajor' 我正在嘗試構建重新排序工作表。非常感謝。mysql查詢不起作用
SELECT ProductMaster_T.ProductName_VC AS PGroup,
StockMain_T.ItemDescription AS Item,
SUM(SaleItems_T.qtymajor) AS sales,
stockbuffers_T.buffer_qty AS BufferQty,
(stkbalance_T.AJ1+stkbalance_T.AR2+stkbalance_T.AD3+stkbalance_T.DX4) AS Stock,
(stkbalance_T.AJ1+stkbalance_T.AR2+stkbalance_T.AD3+stkbalance_T.DX4)-stockbuffers_T.buffer_qty AS Result
FROM ProductMaster_T, StockMain_T, stockbuffers_T, stkbalance_T
WHERE StockMain_T.ItemCode = stockbuffers_T.itemcode
AND
StockMain_T.ItemCode = stkbalance_T.itemid
AND
ProductMaster_T.ProductID = StockMain_T.ProdID
AND
SaleItems_T.ItemID = StockMain_T.ItemCode
ORDER BY
ProductName_VC,ItemDescription ASC
@awerti saleItems_T的表結構如下 INV,項目,qtymajor,計量單位,價格。每一件物品都會添加一行 – mmdel