1
I have tables in the database that relate. A (t.a) has four lines that relate to the other four lines of (t.b) The query is made by means of a (user.id) that exists in the two tables.
The problem happens in the return of the query that repeats 12 more lines ? How can I treat this error ? Below follows 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: http://elevsaude.webstrucs.com/tabelas/elevsaude/operadora/1
Depending on the query Join returns 'duplicated' records, has some special reason to use the
left join
?– rray
Related: What is the difference between INNER JOIN and OUTER JOIN?
– rray
Organizes data from table b with a. Without the listing it is not synchronized: data. a, data. a, data. a, data. a, data. a.
– João Carlos
Exchange the
left
forinner
see if it shows the expected result.– rray
only lists one record.
– João Carlos
I need you to list the other related.
– João Carlos
Add the structures of your tables. How many records do you have in each one? What is the correct query return? This can be useful: Correct way to make a great Inner Join
– Emerson JS