我在我的项目中使用 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();
}
这是执行后的错误
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
我尝试了不同的方法但没有结果。谢谢
原文由 Tojo 发布,翻译遵循 CC BY-SA 4.0 许可协议
也使用
order_by
子句例子( 最好不要做)