[英]How to use Join | codeigniter | sql |
我正在嘗試使用聯接來匹配2個表
我有表user_to_designment
和
我有桌子的用戶
我想匹配user_id
上的表(它們都具有該值),我嘗試了多種方法來做到這一點。
現在是我的代碼:
$this->codeignitercrud->join ( 'join', 'user_to_designment', 'user_id' 'user_to_designment.user_id=username.user_id' );
但是這段代碼給了我一個錯誤。
我使用codeigniter crud系統: http : //demo.code-abc.com/codeignitercrud/help/index.html
我希望你們能幫助我。
親切的問候,
斯特雷克
this->db->select('*');
$this->db->from('A');
$this->db->join('B','B.client_id=A.client_id');
$result=$this->db->get();
return $result->result();
$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();
你能用下面的代碼嗎
$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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.