lundi 27 mai 2019

How to joins three table on employee Id, but filttering on from and to office Id in codeigniter

"I have created three Tables Named: Employee, Offices,and Transfer Posting. Now understand my issue, in Employee(PK e_id) in Offices(PK o_id) and Transfer Table (here transer_from and transfer_to are the foreign keys of O_id)" I want to join these all three tables and fetch data on e_id, when i fetch data, there I could display the employee detail, he is transfered from one office to another. Actaully, I want to show the name of offices on from and to key id.

In Model, I did code so.

function transfer_posting($id){      
 $this->db->select('*')->from('transfer_posting');
 $this->db->join('Offices','Offices.o_id=transfer_posting.t_p_from');
  $this->db->join('Offices', 'Offices.o_id=transfer_posting.t_p_to');
   $this->db->where_in('transfer_posting.e_id',$id);
   return $this->db->get()->result_array();
   }




Aucun commentaire:

Enregistrer un commentaire