错误1064 SQL语法

时间:2017-09-10 15:04:58

标签: php mysql sql codeigniter mariadb

我收到错误1064。

您的SQL语法有错误;检查与您的MariaDB服务器版本对应的手册,以便在第7行的“ORDER BY d3.doctor_id DESC”附近使用正确的语法

行号:81

第81行如下: -

  

d3.doctor_status =“Y”和d7.city_id ='。$ city。' ORDER BY d3.doctor_id   DESC');

    public function doctor_similar($q){
        if(count($q)>0) {
            $spc_id='';
        $city=($this->session->userdata('city_id'));
            foreach ($q as $res_spc) { 
            $spc_id.=$res_spc['department_id'].',';             
        }
        $list=rtrim($spc_id,",");
        $query = $this->db->query('SELECT DISTINCT d3.doctor_id,d3.doctor_name,d3.doctor_specialization FROM Dr_doctors_list AS d3
            JOIN Dr_doctors_spec as d2 ON d2.doctor_id = d3.doctor_id                           
            JOIN Dr_doctors_hosp as d4 ON d3.doctor_id = d4.doctor_id
            JOIN Dr_hospital_lists as d5 ON d4.hospital_id = d5.hospital_id
            JOIN Dr_city_list as d7 ON d5.hospital_city = d7.city_id
            WHERE d2.department_id IN ( '.$list.' )  AND 
            d3.doctor_status="Y" AND d7.city_id ='.$city.' ORDER BY d3.doctor_id DESC');

        return $query->result_array();
        } else {
            return '';

        }
    }

0 个答案:

没有答案