dongyu9850
2013-03-21 16:58
浏览 52
已采纳

在codeigniter中交叉加入?

I'm trying this

$this->db->join('tableTwo as b','','CROSS');
$result = $this->db->get('tableOne as a')->result(); 

Some solution?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试这个

  $ this->  db-> join('tableTwo as b','','CROSS'); 
 $ result = $ this-> db-> get('tableOne as a') - > result();  
   
 
 

某种解决方案?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duanmi3476 2013-03-21 17:59
    已采纳

    Solution for cross join in codeigniter:

    $this->db->join('tableTwo as b','true');
    $result = $this->db->get('tableOne as a')->result(); 
    
    点赞 评论
  • dsxgby126001 2013-03-27 19:22

    You should use it this way:

    $this->db->join('tableTwo as b','true');
    $result = $this->db->get('tableOne as a')->result(); 
    
    点赞 评论
  • dongziche8030 2018-09-11 17:47

    In codeigniter 3, You can add cross join query builder by

    $this->db->join('tableTwo as b','1=1');                    //true relation
    $result = $this->db->get('tableOne as a')->result(); 
    

    Or by passing an array in from method or get methods

    $result = $this->db->get(['tableOne as a','tableTwo as b'])->result(); 
    

    or

    $result = $this->db->from(['tableOne as a','tableTwo as b'])
    get()->result();     //by this method you can add as many table you want to join
    

    or by passing one table in from and other in get method

    $result = $this->db->from('tableOne as a')
    get('tableTwo as b')->result(); 
    
    点赞 评论

相关推荐 更多相似问题