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.
Read more detail on https://ellislab.com/codeigniter/user-guide/database/active_record.html
$this->db->select('*'); $this->db->join('table2', 'table2.ID = table1.ID'); $this->db->join('table3', 'table3.ID = table1.ID'); $this->db->from('table1');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 https://ellislab.com/codeigniter/user-guide/database/active_record.html
Comments
Post a Comment