I have the following query
SELECT
h.cod_hoja,p.nombre,
p.universidad,
d.nombre_diagnostico,
h.hojaEvolucion,
h.planEvolucion,
h.fecha_consulta,
h.hora_consulta
FROM hoja_evolucion as h
JOIN paciente_hoja as ph on ph.cod_hojaFK = h.cod_hoja
JOIN pacientes as p on p.cedula= ph.cedulaFK
JOIN citas as c ON c.cedulaFK = p.cedula
JOIN diagnostico as d ON c.cod_diagnosticoFK = d.cod_diagnostico
WHERE h.cod_hoja = (select MAX(cod_hoja) from hoja_evolucion)
I need that in theory I return the data selected from the last record inserted in sheet_evolution. Dog is returning two records to me the same leaf_code, which I do not know why it happens, since leaf_code is the primary key, so it can not be repeated.