join query in codeigniter Example Tutorial

Today, We want to share with you join query in codeigniter Example Tutorial.In this post we will show you joins in codeigniter, hear for join two tables in codeigniter we will give you demo and example for implement.In this post, we will learn about join three tables in codeigniter with an example.

join query in codeigniter Example Tutorial

There are the Following The simple About join same table in codeigniter Full Information With Example and source code.

As I will cover this Post with live Working example to develop joins table query in codeigniter, so the joins query with where condition in codeigniter is used for this example is following below.

CodeIgniter – Join Query

CodeIgniter Joins tutorial – How to use Inner Join Clause, Left Join / Right Join Clause, Cross Joins Clause, Advanced Joins Clauses, Sub-Query Joins etc.

  Update Query In Codeigniter Example Tutorial

CodeIgniter Joins query function is used to retrive the data result from multiple Database tables. The joins types are MySQL normal joins, inner joins, left joins as well as right joins.

join query in codeigniter Example Tutorial
join query in codeigniter Example Tutorial

How to JOIN Tables in Codeigniter

Hear we are use join() method to join 2 Database table or more then 2 database tables in codeigniter model.we are using join() method for Normal Joins, Joins With Condition, Joins with multiple tables and Joins with specific type Query likeleft, right, inner, outer, right outer, left outer.

Normal Join

$this->db->select('tbl_member.membername,tbl_member.memberid,tbl_membertype.typee');
$this->db->from('tbl_member');
$this->db->join('tbl_membertype','tbl_membertype.membertypeid=tbl_member.membertypeid');
$query=$this->db->get();
$data=$query->result_array();

SELECT `tbl_member`.`membername`, `tbl_member`.`memberid`, `tbl_membertype`.`type` 
FROM (`tbl_member`) 
JOIN `tbl_membertype` ON `tbl_membertype`.`membertypeid`=`tbl_member`.`membertypeid`

Join With Condition

$this->db->select('tbl_member.membername,tbl_member.memberid,tbl_membertype.typee');
$this->db->from('tbl_member');
$this->db->join('tbl_membertype','tbl_membertype.membertypeid=tbl_member.membertypeid');
$this->db->where('tbl_membertype','admin');
$query=$this->db->get();
$data= $query->result_array();

SELECT `tbl_member`.`membername`, `tbl_member`.`memberid`, `tbl_membertype`.`type` 
FROM (`tbl_member`) 
JOIN `tbl_membertype` ON `tbl_membertype`.`membertypeid`=`tbl_member`.`membertypeid`

Inner Join

Example : 1

Used Two MySQL Database table Inner Join in codeigniter

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

$this->db->select('tbl_member.membername,tbl_member.memberid,tbl_membertype.type');
$this->db->from('tbl_member');
$this->db->join('tbl_membertype','tbl_membertype.membertypeid=tbl_member.membertypeid','inner');
$query=$this->db->get();

SELECT `tbl_member`.`membername`, `tbl_member`.`memberid`, `tbl_membertype`.`typee` 
FROM (`tbl_member`) 
INNER JOIN `tbl_membertype` ON `tbl_membertype`.`membertypeid`=`tbl_member`.`membertypeid`

Example : 2

  laravel permissions Tutorial with Example

Used Three MySQL Database table Inner Join in codeigniter

$this->db->select('membername,amount, configdescription');
$this->db->from('tbl_member');
$this->db->join('tbl_memberplan','tbl_memberplan.memberid=tbl_member.memberid','inner');		
$this->db->join('tbl_plan',
            'tbl_memberplan.plan_config_id=tbl_plan.configid','inner');

SELECT `membername`, `amount`, `configdescription` 
FROM (`tbl_member`) 
INNER JOIN `tbl_memberplan` ON `tbl_memberplan`.`memberid`=`tbl_member`.`memberid` 
INNER JOIN `tbl_plan` ON `tbl_memberplan`.`plan_config_id`=`tbl_plan`.`configid`

Left Join

Used Two MySQL Database table Left Join in codeigniter

$this->db->select('tbl_member.membername,tbl_member.memberid,tbl_membertype.type');
$this->db->from('tbl_member');
$this->db->join('tbl_membertype','tbl_membertype.membertypeid=tbl_member.membertypeid','Left');
$query=$this->db->get();

SELECT `tbl_member`.`membername`, `tbl_member`.`memberid`, `tbl_membertype`.`typee` 
FROM (`tbl_member`) 
Left JOIN `tbl_membertype` ON `tbl_membertype`.`membertypeid`=`tbl_member`.`membertypeid`

Right Join

Used Two MySQL Database table Right Join in codeigniter

$this->db->select('tbl_member.membername,tbl_member.memberid,tbl_membertype.type');
$this->db->from('tbl_member');
$this->db->join('tbl_membertype','tbl_membertype.membertypeid=tbl_member.membertypeid','Right');
$query=$this->db->get();

SELECT `tbl_member`.`membername`, `tbl_member`.`memberid`, `tbl_membertype`.`typee` 
FROM (`tbl_member`) 
Right JOIN `tbl_membertype` ON `tbl_membertype`.`membertypeid`=`tbl_member`.`membertypeid`

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about update joins 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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   select Query In Codeigniter Example Tutorial
  2.   jQuery AJAX Dynamic Treeview Menu using PHP, MySQL
  3.   delete Query In Codeigniter Example Tutorial
  4.   Update query in codeigniter Example
  5.   Upload Multiple Images Preview using PHP
  6.   Laravel Get Route Parameters in middleware Example
  7.   Vue.js Alert popup-Dialog Box using PHP and CSS
  8.   echo and print difference in php
  9.   codeigniter print last query - PHP Examples
  10.   Validating Woocommerce webhook using HMAC in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *