Friday, November 14, 2014

How To Join Multiple Tables in Codeigniter?

By using CodeIgniter's Active Record class, you can just use the join method multiple times to join multiple tables.
$this->db->join('table2', 'table2.ID = table1.ID');
$this->db->join('table3', 'table3.ID = table1.ID');
Permits you to write the JOIN portion of your query. If you need a specific type of JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer.
$this->db->join('table4', 'table4.ID = table1.ID', 'left');
// Produces: LEFT JOIN table4 ON table4.ID = table1.ID

Read more detail on

1 comment: