这是我的问题:
SELECT
FO.Placement_date, FO.Delivery_date, FO.Order_Id, FO.Cid,
CPD.Name, FOD.Product, FOD.Type, FOD.Article_Quantity,
FOD.Quantity_In_Metre, FOD.Price_Per_Metre, FPD.Total,
Discount, FPD.OfferDiscount, FPD.ExtraCharges
FROM
F_Orders_Details FOD
INNER JOIN
F_PaymentDetails FPD
INNER JOIN
F_Orders FO ON FO.Order_Id = FOD.Order_Id
INNER JOIN
CustomerIds CPD ON CPD.Cid = FO.Cid
AND CPD.BranchId = FO.BranchId
WHERE
FO.Placement_Date BETWEEN '2017-10-01' AND '2017-10-31'
AND FO.branchid = '1'
ORDER BY
FO.Placement_Date
我没有发现任何错误。
答案 0 :(得分:1)
您在第一个内部联接上缺少与FOD和FDP相关的ON子句。我稍微重新格式化了代码,以便您可以更轻松地发现它:
SELECT FO.Placement_date,
FO.Delivery_date,
FO.Order_Id,
FO.Cid,
CPD.Name,
FOD.Product,
FOD.Type,
FOD.Article_Quantity,
FOD.Quantity_In_Metre,
FOD.Price_Per_Metre,
FPD.Total,
FPD.Discount,
FPD.OfferDiscount,
FPD.ExtraCharges
FROM F_Orders_Details FOD
INNER JOIN F_PaymentDetails FPD /*On what?*/
INNER JOIN F_Orders FO
ON FO.Order_Id = FOD.Order_Id
INNER JOIN CustomerIds CPD
ON CPD.Cid = FO.Cid
AND CPD.BranchId = FO.BranchId
WHERE FO.Placement_Date BETWEEN '2017-10-01' AND '2017-10-31'
AND FO.branchid = '1'
ORDER BY FO.Placement_Date