我收到此错误 您的SQL语法错误;检查对应于你的MySQL服务器版本使用附近的“)) AS name FROM (
resource_details ) JOIN
位置ON
reso_dtail_location`”在行3Mysql group_concat查询给出错误
代码如下
$this->db->select('loc_country,CONCAT(s_name , ":", GROUP_CONCAT(DISTINCT dist_name
ORDER BY dist_name ASC
SEPARATOR ",")) AS name ');
$this->db->from('resource_details');
//join
$this->db->join('location','reso_dtail_location=loc_id');
$this->db->join('go_state', 'go_stste_id = loc_state', 'left');
$this->db->join('go_country', 'num = loc_country', 'left');
$this->db->join('go_dist', 'id = loc_district', 'left');
$this->db->where('loc_id !=1 AND loc_id !=2');
$this->db->group_by('country_name');
$query = $this->db->get();
不确定CodeIgniter创建的完整语句是什么,但是您可能希望将's_name'添加到您的“GROUP BY”列表中 –
对于复杂的操作,建议使用'$ this-> db-> query('YOUR PLAIN QUERY HERE');'[Docs](https://codeigniter.com/userguide3/database/results.html)。 – Tpojka