小编Toj*_*ojo的帖子

使用 CodeIgniter 分组

我在我的项目中使用 CodeIgniter,这是我在模型中的代码

public function group_all_ville(){  
        $this->db->select('*');
        $this->db->from('departement');
        $this->db->join('villes', 'villes.num_dept = departement.num_dept');
        $this->db->group_by('nom_dept'); 
        $query = $this->db->get(); 
        return $query->result();
    }
Run Code Online (Sandbox Code Playgroud)

这是执行后的错误

A Database Error Occurred

Error Number: 1055

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

SELECT * FROM `departement` JOIN `villes` ON `villes`.`num_dept` = `departement`.`num_dept` GROUP BY `nom_dept`

Filename: C:/wamp64/www/pneu/system/database/DB_driver.php

Line Number: 691
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的方法,但没有任何结果。谢谢

php mysql join group-by codeigniter

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

codeigniter ×1

group-by ×1

join ×1

mysql ×1

php ×1