[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?