我想在codeigniter中加入2个表,但它不起作用

时间:2017-08-10 11:18:24

标签: php codeigniter

我的代码是

 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' );
    $this->db->join('bk_ctoe as C', 'A.ID=C.employee_id' );
return  $this->db->get()->result();
} 
 same as
  SELECT * FROM `bk_users` as `A` JOIN `bk_ctoe` as `B` ON 
    `A`.`ID`=`B`.`customer_id` JOIN `bk_ctoe` as `C` ON 
    `A`.`ID`=`C`.`employee_id`

此查询返回空列。我还要添加图片以便更好地理解enter image description here提前感谢

3 个答案:

答案 0 :(得分:1)

尝试使用CI中的以下代码更改您的方法,如下所示。这将返回与customer_idemployee_id

匹配的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();
} 

答案 1 :(得分:0)

  Editable editable = yourEditText.getText();
    int charCount = mDigits.getSelectionEnd();
    if (charCount > 0) {
    editable.delete(charCount - 1, charCount);
    }

答案 2 :(得分: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;