I recently migrated my clients legacy infrastructure which entailed moving there old MySQL 5.0 database into a MySQL 8.0 database (We had some other issues while migrating to Server 2016 that meant we had to do this)
Anyway the client has contacted me today as one of there queries is not working and I can't get to the bottom of it.
It appears as if the following line is used on most / nearly all queries are not working.
GROUP BY L.GrowerID, L.DCropID, C.Variety, C.Crop, L.SizeID DESC, S.Size;
Full Query:
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;
If I remove
GROUP BY L.GrowerID, L.DCropID, C.Variety, C.Crop, L.SizeID DESC, S.Size;
It comes back with completely blank results but it does run with no syntax errors.
Also worth mentioning, if I remove the ASC
and (or) DESC
the query runs without ascending & descending filtering applied - Which is slightly better not not sufficient for my client.
Please see below syntax errors I receive when using some of the faulting queries.
[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
I am no MySQL expert this has merely landed on my desk... I'm sure you understand.
Any help would be great.