簡體   English   中英

Codeigniter中如何在沒有條件的情況下選擇聯接多個表?

[英]How to select join multiple table without conditional in Codeigniter?

我想在codeigniter中使用join選擇多個表,但是我不想像下面的代碼那樣設置任何條件

public function get_invoice(){

    $this->db->select('isp.*,dp.*,ip.*'); 
    $this->db->from('isp');
    $this->db->join('dp','dp.status = isp.status');
    $this->db->join('isp','isp.status = ip.status');
    $this->db->limit(5000);
    $this->query =  $this->db->get();
    if($this->query->num_rows()>0){
        return $this->query->result();
    }

}

但是我想在沒有條件的情況下獲取該表中的所有數據,但在join語句中必須使用條件的。

那么如何在沒有條件的情況下從多個表中選擇數據?

感謝幫助

是的,您可以無條件加入查詢。 INNER LEFT RIGHT JOINS需要條件。因此您可以進行Cross JOIN。

public function get_invoice(){

 $this->db->select('isp.*,dp.*,ip.*'); 
 $this->db->from('isp,dp,ip');
 $this->db->limit(5000);
 $this->query =  $this->db->get();
 if($this->query->num_rows()>0)
 {
    return $this->query->result();
 }

}

但是在Cross JOIN上,如果您的isp有100,dp有20,而ip有50記錄,它將產生(100 * 20 * 50)記錄。我希望您知道CROSS,LEFT,INNER,RIGHT JOIN的作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM