2017-08-10 132 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

我已经完成并发布了答案。谢谢你的帮助。它对你很好 –

相关问题