join query with where condition in codeigniter

Today, We want to share with you left join in codeigniter.In this post we will show you join query in codeigniter controller, hear for codeigniter join 3 tables we will give you demo and example for implement.In this post, we will learn about How To Use Joins In CodeIgniter? with an example.

Codeigniter Inner Join With Multiple Tables

$this->db->select('*');
$this->db->from('members');
$this->db->join('profile_image', 'profile_image.member_id = members.id');
$this->db->join('city', 'city.member_id = members.id','left');
$this->db->join('post', 'post.member_id = members.id','left');
$this->db->join('friends', 'friends.member_id = members.id','left');
$this->db->where('members.id', $id); 
$query = $this->db->get();


Result

Select *from members
join profile_image on profile_image.member_id = members.id
left join city on city.member_id = members.id
left join post on post.member_id = members.id
left join friends on friends.member_id = members.id
where members.id = $id

codeigniter join 2 table data

<?php

$this->db->select('tamilrokers.name, infinityknow.something, mobile.another')
     ->from('table1 as tamilrokers')
     ->where('tamilrokers.id', $id)
     ->join('table2 as infinityknow', 'tamilrokers.id = infinityknow.id', 'LEFT')
     ->join('table3 as mobile', 'tamilrokers.id = mobile.id', 'LEFT')
     ->get();
?>

I hope you get an idea about delete query in codeigniter.
I would like to have feedback on my infinityknow.com 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.