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.

Read Also:  How to Open URL in New Tab using PHP

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Get custom product attributes in Woocommerce
  2. Read Also:  How to Remove all special characters from a string in php?
  3. Read Also:  Laravel All Where eloquent methods with Examples
  4. Read Also:  Wordpress Next Previous Article/post using CSS
  5. Read Also:  How to get last inserted id in Laravel
  6. Read Also:  PHP wordpress get timezone Example - MySQL
  7. Read Also:  Laravel 5.7 Route Group Names Example
  8. Read Also:  insert and display data from database in codeigniter
  9. Read Also:  PHP file_get_contents() function Example
  10. Read Also:  Laravel All Where eloquent methods with Examples