Left Join Query in Codeigniter

The LEFT JOIN is sometimes called as LEFT OUTER JOIN and is performed on two database tables – the first table (on the left side) is referred as LEFT TABLE and and the second (on the right side) one as RIGHT TABLE. The LEFT JOIN returns all the rows from the LEFT TABLE along with the matching rows on the RIGHT TABLE.

Let’s create a left join method in codeigniter

$this->db->select('tbl_order.*,tbl_user.fullname');
$this->db->from('tbl_order');
$this->db->join('tbl_user', 'tbl_user.id = tbl_order.user_id','left');
$query = $this->db->get();
return $query->result();

Leave a Reply

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