我最近迁移了我的客户遗留基础设施,这需要将旧的 MySQL 5.0 数据库迁移到 MySQL 8.0 数据库(我们在迁移到 Server 2016 时遇到了一些其他问题,这意味着我们必须这样做)
无论如何,客户今天已与我联系,因为其中一个查询不起作用,我无法深入了解它。
似乎以下行用于大多数/几乎所有查询都不起作用。
GROUP BY L.GrowerID, L.DCropID, C.Variety, C.Crop, L.SizeID DESC, S.Size;
完整查询:
SELECT Cu.Customer, L.DCropID, C.Crop, C.Variety, D.Clone, G.Grower,
S.Size, SUM(L.EndTubers) AS "Tubers", FORMAT(SUM(L.EndWeight),2) AS "Weight"
FROM PotatoLabels.Crop C, PotatoLabels.PLabel2012 L, PotatoLabels.Sizes S,
PotatoLabels.DCrop D, PotatoLabels.Customers Cu, PotatoLabels.Growers G,
PotatoLabels.mmGrades M
WHERE (D.DCropID > 96534 AND Cu.CustomerID = 9 AND G.GrowerID = 1 )
AND L.CustomerID = Cu.CustomerID
AND D.DCropID = L.DCropID
AND C.CropID = D.CropId
AND L.SizeID = S.SizeID
AND L.GrowerID = G.GrowerID
GROUP BY L.GrowerID, L.DCropID, C.Variety, C.Crop, L.SizeID DESC, S.Size;
如果我删除
GROUP BY L.GrowerID, L.DCropID, C.Variety, C.Crop, L.SizeID DESC, S.Size;
它返回完全空白的结果,但运行时没有语法错误。
还值得一提的是,如果我删除ASC
和(或)DESC
查询运行而不应用升序和降序过滤 - 这对我的客户来说稍微好一点还不够。
请参阅以下我在使用一些错误查询时收到的语法错误。
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC, S.Size' at line 12
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, L.SizeID DESC WITH ROLLUP' at line 22
我不是 MySQL 专家,这只是落在我的桌子上......我相信你明白。
任何帮助都会很棒。