P. *_*ick 1 php mysql codeigniter codeigniter-3
当我尝试在 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`
Run Code Online (Sandbox Code Playgroud)
PHP:
$query = $this->db->select("id, keyword, value, language")
->group_by("language")
->get("phrases")
->result();
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索了一下,但不太明白答案,主要是因为查询与 CI 无关,而且非常复杂......如何在 codeigniter 中解决这个问题?
我不想更改任何 MySQL 设置。
小智 5
表达式#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
Run Code Online (Sandbox Code Playgroud)
只需在查询的上方添加以下行即可。
$this->db->query("SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''));");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4301 次 |
| 最近记录: |