• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sql select statement with two foreign key taken from the same table

#2
[eluser]Crackarjack[/eluser]
Code:
$this->db->select(
  'lead.username as username1,
      coor.username as username2,
      J.job_ID,
  J.project_name,
  P.payment_phase,
  E.email_password');
  
  $this->db->from('job_records  J', 'payment AS P', 'email_records AS E');
  $this->db->join('payment AS P', 'P.job_ID = J.job_ID');
  $this->db->join('email_records AS E', 'E.job_ID = E.job_ID');
  $this->db->join('users AS lead','J.job_user_lead_ID=lead.id');
  $this->db->join('users AS coor','J.job_user_coordinator_ID=coor.id');
  $result = $this->db->get();
  $test = $result->result();
  $str = $this->db->last_query();


Messages In This Thread
Sql select statement with two foreign key taken from the same table - by El Forum - 07-20-2012, 02:05 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.