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.
Related
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 ;
'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
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
SELECT sma_quotes.customer as name,
sma_quotes.date as date,
sma_quotes.selecttype as type,
sma_quotes.biller_id as bl_id,
sma_quotes.volume as volume,
sma_quotes.containernumber as cn_no,
sma_quotes.grand_total as total,
sma_sales.paid as paid
FROM sma_quotes
JOIN sma_sales ON sma_sales.quote_id = sma_quotes.id
WHERE name IS 'Everbest Foods'
Error
SQL query: Documentation
MySQL said: Documentation
#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 ''Everbest Foods' LIMIT 0, 25' at line 1
There is no LIMIT in your query, so the error message is suspicious.
However, you want =, not IS:
WHERE sma_quotes.customer = 'Everbest Foods'
I am trying to Update Some row in my database. If I run without limit its working fine but if I run it with limit its giving me error like below
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 '35' at line 1
My Query is like below
UPDATE number_list SET sync = 0 WHERE server = 1 ORDER by id ASC LIMIT 0,35
Let me know if someone can correct me.
You can use limit in an update (in MySQL) but not an offset. So just do:
UPDATE number_list
SET sync = 0
WHERE server = 1
ORDER by id ASC
LIMIT 35;
This is a bit subtle, because SELECT supports offsets. However, it is clear in the syntax diagram for UPDATE.
I'm having trouble figuring out why this query does not work. Names have been sanitized as this is proprietary code.
QRY:
SELECT l.albert, o.ben, m.caleb, m.dennis, m.edgar
FROM octopus o, lorax l, monkey m
WHERE o.ben = l.ben
AND l.franklin= m.franklin
AND o.ben= :ben
ORDER BY l.albert DESC
LIMIT 1
Here is the error that I get:
MySQL Error: 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 'QRY: SELECT l.albert, o.ben, m.caleb, m.dennis, m' at line 1
It seems like you have
"QRY: "
at the beginning of your query. It should start with
"SELECT ...
I got this weird error after trying to execute a query on a large table:
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 '/*100,3),
'%') AS Percentage FROM
INFORMATION_SCHEMA.PROFILING WHERE
QUERY_ID=' at line 1
What does it mean?
EDIT == this is the query
update cities w, states s set w.region_id = s.id
where s.code = w.region and w.country_id = s.country_id
The cities table has around 3 million entries and the states table around 6000
Just for the record I executed this query using a mysql client Navicat.
SQL supports C-style comments:
/* ... */
so it looks like /*100,3 is being interpreted as the beginning of a comment and that comment is wrecking the syntax of the rest of the SQL.