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

[eluser]Unknown[/eluser]
Hi All,

This is my first time here and I'm stuck when trying to write a sql query.

I have 3 tables named: patient, group and group_patient.

group_patient contains the id's of patient and group.

A patient can have multiple groups. I have the following query:

$this -> db -> select('patient.naam as patient_naam, ecaris_nr, geslacht, group.naam as group_naam');
$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();

Yet i'm getting a array with the same patient and echt a different group, what I want is that the patient object has an array of groups.

What am I doing wrong?


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