我在其他人构建的MS Access数据库中找到了此查询:
SELECT
tblWorkOrder.WorkOrderNum
, tblWorkOrder.SprayTypes
, tblWorkOrder.Description
, tblWorkOrderMaterials.ChemicalName
, tblWorkOrderMaterials.RatePerAcre
, tblMaterials.ApplicationUnit
, tblMaterials.DryOrLiquid
, tblWorkOrderMaterials.ID
FROM (tblMaterials
INNER JOIN tblMaterialsDetails ON tblMaterials.ChemicalName = tblMaterialsDetails.ChemicalName)
INNER JOIN (tblWorkOrder
INNER JOIN tblWorkOrderMaterials ON tblWorkOrder.WorkOrderNum = tblWorkOrderMaterials.WorkOrderNum) ON tblMaterials.ChemicalName = tblWorkOrderMaterials.ChemicalName
WHERE (((tblMaterialsDetails.CropType) = "Apples"
OR (tblMaterialsDetails.CropType) = "All"))
GROUP BY
tblWorkOrder.WorkOrderNum
, tblWorkOrder.Description
, tblWorkOrderMaterials.ChemicalName
, tblWorkOrderMaterials.RatePerAcre
, tblMaterials.ApplicationUnit
, tblMaterials.DryOrLiquid
, tblWorkOrderMaterials.ID;
查询在Access中运行正常,这就是问题所在。当字段“tblWorkOrder.SprayTypes”包含在SELECT
列表中而不包含在GROUP BY
子句中时,此查询如何运行?它应该导致基于未包含在聚合函数中的字段的错误,对吧?当我将后端迁移到MySQL时,它就像我预期的那样崩溃了所以我想确保我没有错过Access后端版本中的东西。
这是tblWorkOrder和tblSprayTypes:
之间的关系答案 0 :(得分:1)
它成功运行,因为select子句中没有任何内容需要group by子句。没有最小值,最大值,总和,计数或平均值。
group by子句的要点不明确,但这不是你的问题。