Mysql error after upgrade to 8, only_full_group_by error

455 Views Asked by At

This line give me the error:

Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'hng_1.tags.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

foreach($groups as $group)
    {
            $query = mysqli_query($verbindung, "SELECT * FROM (SELECT *, COUNT(id) AS c FROM tags WHERE typ='" . mysqli_real_escape_string($verbindung, $group) . "' GROUP BY slug ORDER BY c DESC LIMIT 9) AS i ORDER BY i.tag ASC") or die("Error: " . mysqli_error($verbindung));

            while ($row = mysqli_fetch_array($query)) {
                    $tmp_tags[] = $row;
            }
    }

How can I change the query to fix this error?

1

There are 1 best solutions below

0
Raymond Rosenberg On

For anyone else who is interested, I solved this problem. I added id to GROUP BY so it now know what to select.

GROUP BY slug, id 

fix it.