Join returns duplicate records mysql codeigniter

0

I'm doing a coansulta to 3 tables that have a common id, but it returns duplicate records twice each one of them

    public function select_informacion_encargados(){
        $this->db->select('encargado.nombre, encargado.materno, encargado.paterno,email.email, telefono.telefono, prestadores_servicios.cargo_encargado');
        $this->db->from($this->table);
        $this->db->join("email","email.id_servicios  = prestadores_servicios.id_servicios");
        $this->db->join("telefono","telefono.id_servicios  = prestadores_servicios.id_servicios");
        $this->db->join("encargado","encargado.id_servicios  = prestadores_servicios.id_servicios");
        $this->db->where("prestadores_servicios.id_servicios", 2);
        $result = $this->db->get()->result();

        return $result;
    }

How could I do it so that I do not duplicate the records

    
asked by Jorge Luis Avila Muñoz 25.05.2018 в 07:59
source

1 answer

0

You have to make a distinct before the select.

public function select_informacion_encargados(){
    $this->db->distinct();
    $this->db->select('encargado.nombre, encargado.materno, encargado.paterno,email.email, telefono.telefono, prestadores_servicios.cargo_encargado');
    ....
}

Source

    
answered by 25.05.2018 в 08:35