我收到此錯誤 您的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