2017-08-10 64 views
1

我的代碼是我想加盟笨2個表,但它不工作

​​

該查詢返回的空列。我還添加圖片,以便更好地瞭解enter image description here在此先感謝

+0

你說的數據與原始SQL正確返回,但而不是當你通過代碼點燃器建立查詢?否則,這不是一個CI問題。 – Utkanos

+0

沒有我只是說這個查詢在ci中返回空字符串,當我在我的數據庫中使用raq查詢時,返回的空顏色不是我想要選擇的實際數據 –

+0

INNER JOIN需要引用兩側的匹配,確保您的數據在那裏。 – DontVoteMeDown

回答

0
function admin_profile() 
{ 
    $this->db->select('B.FNAME as customer,B.email,B.contact, C.FNAME AS 
    employee,B.active as active_user,A.active as assigned'); 
    $this->db->from('bk_ctoe as A'); 
    $this->db->join('bk_users B', 'B.ID=A.customer_id'); 
    $this->db->join('bk_users C', 'C.ID=A.employee_id'); 
return $this->db->get()->result(); 

} 
1

請嘗試在CI中的以下代碼更改您的方法,如下所示。這將返回匹配的ID與任何customer_idemployee_id

function admin_profile() 
{ 
    $this->db->select('*'); 
    $this->db->from('bk_users as A'); 
    $this->db->join('bk_ctoe as B', 'A.ID=B.customer_id OR A.ID=B.employee_id');  
    return $this->db->get()->result(); 
} 
+0

感謝您的回答 –

0

嘗試使用下面的代碼爲例,

$this->db->select('*'); 
    $this->db->from('login'); 
    $this->db->join('registration', 'registration.userid = login.userid'); 
    //$query=$this->db->get('registration'); 
    $this->db->where('login.status',2); 
    $query=$this->db->get(); 
    return $query; 
+0

我已經完成併發布了答案。謝謝你的幫助。它對你很好 –

相關問題