3
I had a certain MYSQL query that was working correctly.
This is the consultation:
SELECT *, count(*) as count FROM `post_hashtags`
WHERE `created_at` BETWEEN ? AND ?
AND (SELECT count(*) AS `aggregate`
FROM `post`
WHERE `post`.`id` = post_hashtags.post_id
AND `status` = 0
AND `post_privacidade_id` = 1) >= ?
GROUP BY `hashtag`
ORDER BY `count` DESC, created_at DESC
LIMIT 5
But after upgrading Mysql to version 5.7 on my machine, I started getting this error:
Syntax error or access Violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'post_hashtags.id' which is not functionally dependent on Columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Does anyone know what’s going on? I’ve never received this message before.
Have something considered wrong in the query, for the new version of Mysql?
Note: It’s good to get refactoring advice. I know my query is not great things there, but as it is an old system that is being maintained, I can not touch anything. I just really need to know how to make this mistake stop.
– Wallace Maxters
Maybe it’s dup of this => http://answall.com/q/164495/91
– rray
In what sense is this question duplicated? Where reports the error in the linked question?
– Wallace Maxters
In that comment
– rray