2016-05-31 7 views
0

私は彼らが(私はuser_id上のテーブルに一致するようにしたい私はテーブルのユーザーに参加方法|コードシグネチャ| SQL |

を持って、私はテーブルにuser_to_designment

そして

を持つ2つのテーブル

に一致するように結合を使用しようとしていますどちらもその値を持っています) 私はそれを行うために複数の方法を試みました。

$this->codeignitercrud->join ('join', 'user_to_designment', 'user_id' 'user_to_designment.user_id=username.user_id' ); 

しかし、このコードは私にエラーを与える:

これが今の私のコードです。私はあなたたちは私を助けることができると思いますhttp://demo.code-abc.com/codeignitercrud/help/index.html

私はCodeIgniterのCRUDシステムを使用しています。

敬具、

Sterrek

答えて

0
$this->db->select('*'); 
    $this->db->from(FIRST TABLE NAME); 
    // IF Field name is common in both table use this way 
    $this->db->join_using(SECOND TABLE NAME,'FIELD NAME'); 
    //other wise 
    $this->db->join(SECOND TABLE NAME,'1st table FIELD NAME=2nd table Field name');  
    $query = $this->db->get(); 
0

あなたはあなたの答えのための

$this->db->select("b.user_id); $this->db->from('username as b'); $this->db->join('user_to_designment as bo','bo.user_id=b.user_id',inner);

1
this->db->select('*'); 
    $this->db->from('A'); 
    $this->db->join('B','B.client_id=A.client_id'); 


    $result=$this->db->get(); 
    return $result->result(); 
+0

ちょっとおかげコードの下に使用していただけます:私は、この行を編集することができますどのように私テーブル? @dharmesh:$ this-> db-> join( 'B'、 'B.client_id = A.client_id'); –

+0

'A'の代わりに基本表名を、 'B'の代わりに2次表名を入れます。 –