Welcome Guest, Not a member yet? Register   Sign In
MySQL Join result
#1

[eluser]ibnclaudius[/eluser]
I have two tables that have fields with the same name, how can I select each one?

Code:
$data['get_subjects'] = $this->mb_database->get_subjects($this->session->userdata('school_id'));

Code:
public function get_subjects($school_id)
{
  $query = $this->db->select('*')->from($this->subjects_table, $this->classes_table)->join($this->classes_table, $this->classes_table . '.id = ' . $this->subjects_table . '.classes_id', 'INNER')->where($this->classes_table . '.id', $school_id)->get();

  if ($query->num_rows > 0)
  {
   return $query;
  }
  else
  {
   return FALSE;
  }
}

Code:
<?php foreach($get_subjects->result_array() as $row) : ?>
     <p>nome: &lt;?php echo $row['name']?&gt;</p><br />
    &lt;?php endforeach; ?&gt;

For example, when I do the foreach, it always return the name from $this->classes_table


Messages In This Thread
MySQL Join result - by El Forum - 01-28-2012, 05:45 PM
MySQL Join result - by El Forum - 01-29-2012, 06:13 AM
MySQL Join result - by El Forum - 01-29-2012, 11:42 AM
MySQL Join result - by El Forum - 01-29-2012, 12:13 PM
MySQL Join result - by El Forum - 01-29-2012, 02:03 PM
MySQL Join result - by El Forum - 01-29-2012, 02:14 PM
MySQL Join result - by El Forum - 01-29-2012, 02:16 PM
MySQL Join result - by El Forum - 01-29-2012, 02:28 PM
MySQL Join result - by El Forum - 01-29-2012, 02:29 PM
MySQL Join result - by El Forum - 01-29-2012, 02:48 PM
MySQL Join result - by El Forum - 01-29-2012, 02:51 PM
MySQL Join result - by El Forum - 01-29-2012, 02:57 PM
MySQL Join result - by El Forum - 01-29-2012, 03:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB