Select Join for two columns in codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Select Join for two columns in codeigniter (/showthread.php?tid=66029) |
Select Join for two columns in codeigniter - majimazuri21 - 08-25-2016 Hello everybody; Code: Table 1 I would like to know how to select data with codeigniter query in order to get result like this Code: product_name location added_by updated_by I have tried with join but added_by column and updated_by column display same data. RE: Select Join for two columns in codeigniter - majimazuri21 - 08-25-2016 I have got answer $this->db->select('t1.product_name,t1.location, CONCAT(t2_1.first_name, " ", t2_1.last_name) AS added_by, CONCAT(t2_2.first_name, " ", t2_2.last_name) AS updated_by'); $this->db->from('Table 1 t1'); $this->db->join('Table 2 t2_1', 't2_1.id = t1.added_by', 'left'); $this->db->join('Table 2 t2_2', 't2_2.id = t1.updated_by', 'left'); $query = $this->db->get(); return $query->result(); |