inner join repeated data (mysql)

1

Hello people, good afternoon, I have to take data from several tables (related to each other), it brings me the data I need, but it repeats, I have given it several times and I do not see where the fault lies, my query is so:

SELECT
c.idCita, pa.idPaciente, prof.idRegistro, c.fecha_cita,
prof.nombres, prof.ape_pat, prof.ape_mat,
pa.rut_paciente, pa.nombres_paciente, pa.ape_pat, pa.ape_mat, pa.fecha_nacimiento,
h.hora,
ba.numBox
FROM
paciente pa INNER JOIN cita c
ON pa.idPaciente = c.idPaciente,
horas_atencion ha INNER JOIN hora h
ON  ha.idHora = h.idHora,
boxes_atencion ba INNER JOIN horas_atencion sa
ON ba.idBox = sa.idBox,
profesional prof INNER JOIN horas_atencion h1
ON prof.idRegistro = h1.idRegistro
WHERE c.estado_cita= 'REGISTRADA';

Greetings to all, I appreciate your support from now ...

    
asked by Nicolas Ezequiel Almonacid 16.08.2018 в 17:29
source

1 answer

0

Dear, you can try in the following way:

                SELECT
                c.idCita, 
                pa.idPaciente, 
                prof.idRegistro, 
                c.fecha_cita,
                prof.nombres, 
                prof.ape_pat, 
                prof.ape_mat,
                pa.rut_paciente, 
                pa.nombres_paciente, 
                pa.ape_pat, 
                pa.ape_mat, 
                pa.fecha_nacimiento,
                h.hora,
                ba.numBox

                FROM paciente pa
                INNER JOIN cita c              ON pa.idPaciente = c.idPaciente, 

                horas_atencion ha

                INNER JOIN hora h              ON h.idHora = ha.idHora

                INNER JOIN boxes_atencion ba   ON ba.idBox = ha.idBox

                INNER JOIN profesional prof    ON prof.idRegistro = ha.idRegistro

                WHERE c.estado_cita= 'REGISTRADA';
    
answered by 16.08.2018 / 18:15
source