Home > Enterprise >  ERROR 1064 (42000): You have an error in your SQL syntax; 'DESC'
ERROR 1064 (42000): You have an error in your SQL syntax; 'DESC'

Time:09-04

Hello, I have the following problem, I use the world.sql schema and I can't display my query in a descending way, I get the following error: 1064 (42000): 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'

I can't find a way to solve the problem other than storing the result in a table and then applying DESC. Could someone guide me what I could do or where I could investigate?

SELECT la.language, la.Isofficial AS Isofficial ,SUM(country.Population * la.Percentage / 100) pop_tot FROM country INNER JOIN countrylanguage AS la ON la.countryCode = country.Code WHERE  la.language != "Spanish" AND la.Isofficial = "T" GROUP BY la.Language DESC ;

CodePudding user response:

Replace

GROUP BY la.Language DESC;

with

GROUP BY la.Language 
ORDER BY la.Language DESC;

Which will work in whatever MySQL server version you have.

BTW, I've tested the first syntax and it works well in version 5.5

CodePudding user response:

'Prior to MySQL 8.0.13, MySQL supported a nonstandard syntax extension that permitted explicit ASC or DESC designators for GROUP BY columns...As of MySQL 8.0.13, the GROUP BY extension is no longer supported: ASC or DESC designators for GROUP BY columns are not permitted.' - https://dev.mysql.com/doc/refman/8.0/en/select.html

  • Related