gpt4 book ai didi

php - CodeIgniter 3 - 非聚合列分组依据

转载 作者:行者123 更新时间:2023-11-29 10:22:26 25 4
gpt4 key购买 nike

当我尝试在 CodeIgniter 3 中运行此查询时,出现以下错误:

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

SELECT `id`, `keyword`, `value`, `language` FROM `phrases` GROUP BY `language`

PHP:

$query = $this->db->select("id, keyword, value, language")
->group_by("language")
->get("phrases")
->result();

我用谷歌搜索了一下,但不太明白答案,主要是因为查询与 CI 无关,而且非常复杂......如何在 codeigniter 中解决这个问题?

我不想更改任何 MySQL 设置。

最佳答案

表达式#1

SELECT list is not in GROUP BY clause and contains nonaggregated column 'spd.quantity' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

只需在查询的上方添加以下行即可。

$this->db->query("SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''));");

关于php - CodeIgniter 3 - 非聚合列分组依据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48992774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com