2015-11-03 26 views
0

我有一個數據庫查詢來選擇不同的類別。但是,我有2個連接表,我的獨特查詢不起作用,因爲它返回重複的類別。我必須做什麼代碼調整?這是我的查詢代碼。Codeigniter截然不同的查詢不起作用

$query = $this->db->distinct() 
        ->select('tbl_par.*, tbl_category.category_name') 
        ->or_like($array_like_param) 
        ->from($this->table_par) 
        ->join($this->table_cat,$this->table_cat.'.ID ='.$this->table_par.'.category') 
        ->get(); 

回答

0

試試這個

$this->db->select('tbl_par.*, distinct tbl_category.category_name'); 
$this->db->or_like($array_like_param) 
$this->db->from($this->table_par) 
$this->db->join($this->table_cat,$this->table_cat.'.ID ='.$this->table_par.'.category') 
$query=$this->db->get();