Codeigniter multiple join conditions on a single table

Basically, I want to join a table where col in table A corresponds to col in table B and where col in table B is 0. I use the codeigniters active write class.

Thanks in advance.

+6
sql join codeigniter
source share
1 answer

Something like this should work:

$this->db->join('B', 'aCol = bCol AND bOtherCol = 0'); $this->db->get('A'); 

Optionally, a third argument can be specified for the join method to indicate whether a left or right join should be performed. For example, to perform a left join:

 $this->db->join('B', 'aCol = bCol AND bOtherCol = 0', 'left'); 
+12
source share

All Articles