I have the following query:
SELECT TableAll.*,
(SELECT COALESCE(SUM(vv.value), 0)
FROM votes vv
WHERE TableAll.id = vv.post_id
AND TableAll.tc = vv.table_code) AS total_votes
FROM
(SELECT @rank1 := @rank1 + 14 `rank`, 17 tc, id, word AS subject, '' name
FROM loghatnameh_dehkhoda,
(SELECT @rank1 := -13) q
WHERE word like "test"
UNION ALL
SELECT @rank2 := @rank2 + 14 `rank`, 18 tc, id, word AS subject, TYPE name
FROM loghatnameh_amid,
(SELECT @rank2 := -12) q
WHERE word like "test"
ORDER BY rank
LIMIT 0,
11) TableAll;
It was working well on MySQL version 5.7.42, and after upgrading to MySQL version 8.0.34, it's getting broken and throwing:
#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 'LIMIT 0, 11 ) TableAll LIMIT 0, 25' at line 6
Any idea how can I fix it?