Join repeats records? [closed]

1

I have tables in the database that relate. A (t.a) has four rows that relate to the other four rows of (t.b) The query is performed by means of a (user.id) that exists in both tables.

Does the problem occur in the return of the query that repeats another 12 lines? How can I handle this error? Below is the code and link:

public function planstypes_head($elev_opename_id) {
   $this->db->select('*');
   $this->db->from('elev_plans_types');
   $this->db->join('elev_share_plans', 'elev_share_plans.elev_opename_id = elev_plans_types.elev_opename_id' , 'left');
   $this->db->where('elev_plans_types.elev_opename_id', $elev_opename_id);
   $query = $this->db->get();
   return $query->result(); 
}

Link: link

    
asked by anonymous 27.06.2016 / 17:01

2 answers

2

Good afternoon. I believe that if you change the line

$this->db->select('*');

To

$this->db->select('elev_plans_types.*');

It will be right. It turns out that if you only put '*', you are having to select the data from the elev_plans_types table and the elev_share_plans table. I hope I have helped.

Oss

    
27.06.2016 / 18:38
1

You should group the records by the main field you are looking for. I believe that if you do $this->db->group_by("elev_plans_types.elev_opename_id"); it works.

    
28.06.2016 / 16:48