我想在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)条记录。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句