How to JOIN three tables in Codeigniter?

Today, We want to share with you codeigniter join 3 tables.In this post we will show you codeigniter join 2 tables, hear for codeigniter join 4 tables we will give you demo and example for implement.In this post, we will learn about Join Query In Codeigniter Example Tutorial with an example.

how to join two different database tables in codeigniter?

Use this code in model

public function funcname($id)
    $this->db->from('Album a'); 
    $this->db->join('Level b', 'b.cat_id=a.cat_id', 'left');
    $this->db->join('Soundtrack c', 'c.movie_id=a.movie_id', 'left');
    $query = $this->db->get(); 
    if($query->num_rows() != 0)
        return $query->result_array();
        return false;

Codeigniter join multiple tables

$this->db->join('account_image', 'account_image.member_id =');
$this->db->join('city', 'city.member_id =','left');
$this->db->join('post', 'post.member_id =','left');
$this->db->join('relatives', 'relatives.member_id =','left');
$this->db->where('', $id); 
$query = $this->db->get();

Will produce

// Select *from members
join account_image on account_image.member_id =
left join city on city.member_id =
left join post on post.member_id =
left join relatives on relatives.member_id =
where = $id

I hope you get an idea about codeigniter join three tables.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment