这一行给了我错误:
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;
}
}
如何更改查询来修复此错误?
最佳答案
对于其他感兴趣的人,我解决了这个问题。我将 id 添加到 GROUP BY,因此它现在知道要选择什么。
GROUP BY slug, id
修复它。
关于php - mysql升级到8后报错,only_full_group_by错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51465991/