我试图将4个表连接在一起,如下图所示: https://imgur.com/a/jukJvSw
我编写的SQL查询返回除TExpiryDate
之外的所有字段,并且我没有在网上遇到任何可以帮助我理解这一点的示例。请帮忙。
SELECT tbPurchaseHeader.PurchaseDate,
tbSupplier.CompanyName,
tbPurchaseDetails.UnitCost,
tbPurchaseDetails.Quantity,
tbPurchaseDetails.Bonus,
tbpurchasedetails.BatchID,
tbBatch.TExpiryDate
FROM ((tbPurchaseDetails
INNER JOIN tbPurchaseHeader
ON tbPurchaseDetails.PurchaseID = tbPurchaseHeader.PurchaseID)
LEFT JOIN tbBatch
ON tbPurchaseDetails.BID = tbBatch.BID)
INNER JOIN tbSupplier
ON tbPurchaseHeader.SupplierID = tbSupplier.SupplierID
WHERE tbPurchaseDetails.ProductID = ?
ORDER BY tbPurchaseHeader.PurchaseDate
答案 0 :(得分:0)
结果BID
在数据库中包含空值。我决定在其他地方建立链接以获取数据。谢谢大家让我意识到这一点。