Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter multiple join conditions on same table

Basically i want to join a table where a col in table A matches a col in table B and where a col in table B is equal to 0. I am using codeigniters active record class.

Thanks in advance.

like image 594
Kyle Avatar asked Sep 24 '10 07:09

Kyle


1 Answers

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');
like image 124
Ton van den Heuvel Avatar answered Oct 21 '22 14:10

Ton van den Heuvel