ASC的语法错误,MySQL 8.0的DESC

时间:2019-03-28 10:35:12

标签: mysql mysql-8.0 mysql-5.0

我最近迁移了客户的旧基础架构,这需要将旧的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专家,这只是落在我的桌子上...我确定您理解。

任何帮助都会很棒。

0 个答案:

没有答案