Welcome Guest, Not a member yet? Register   Sign In
Multiple results join
#3

[eluser]Unknown[/eluser]
[quote author="Stefan Hueg" date="1375189727"][quote author="khallouki" date="1375184062"]
What am I doing wrong?
[/quote]

Nothing, thats how JOINs work. What you want to do can be achieved by this code:

Code:
$this->db->select('patient.id, patient.naam as patient_naam, ecaris_nr, geslacht, group.naam as group_naam, group.id as group_id');
$this->db->from('patient');
$this->db->join('group_patient’, ‘group_patient.patient = patient.id');  
$this->db->join('group’, ‘group_patient.group = group.id');
$result = $this->db->get();
$patients = array();
while ($row = mysql_fetch_assoc($result->result_id))
{
if (!isset($patients[$id]))
{
  $patients[$id] = array(
   'patient_naam' => $row['patient_naam'],
   'ecaris_nr' => $row['ecaris_nr'],
   'geslacht' => $row['geslacht'],
   'groups' => array()
  );
}
$patients[$id]['groups'][$row['group_id']] = $row['group_naam'];
}
[/quote]

Thank you very much!


Messages In This Thread
Multiple results join - by El Forum - 07-30-2013, 04:34 AM
Multiple results join - by El Forum - 07-30-2013, 06:08 AM
Multiple results join - by El Forum - 07-30-2013, 08:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB