I have the following MySQL query:
select SQL_CACHE
SQL_CALC_FOUND_ROWS
stat_users_events_daily.user_id,
stat_users_events_daily.tracking_category_id as tracking_category_id,
IF(ISNULL(tracking_categories.name),"Category not found",tracking_categories.name) as tracking_category_name,
SUM(stat_users_events_daily.sent) AS total_sent,
SUM(stat_users_events_daily.opened) AS total_opened from `stat_users_events_daily` left join `tracking_categories` on `stat_users_events_daily`.`tracking_category_id` = `tracking_categories`.`id` where `stat_date` between 2024-08-25 and 2024-08-25 group by `user_id`, `tracking_category_id` order by `total_opened` desc, `user_id` asc, `tracking_category_id` asc limit 2 offset 0;
It works fine in MySQL 5.7 but in MySQL 8.4 it gives me an error:
SQL 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 'SQL_CALC_FOUND_ROWS
stat_users_events_daily.user_id,
stat_users_events_daily.t' at line 2
Error position: line: 1
Any explanation why please?
According to the release notes, the SQL_CACHE modifier was removed in MySQL 8.0.3
The deprecated query cache has been removed. Removal includes these items: ... The SQL_CACHE SELECT modifier.
You'll need to remove SQL_CACHE from your query.