Good afternoon, I am trying to generate a class schedule and it took several days without being able to generate the schedule through a query in MySQL.
The query I'm doing in MySQL is the following:
SELECT CONCAT(DATE_FORMAT(h.hora_inicio,"%H:%i")," - ",DATE_FORMAT(h.hora_fin,"%h:%i")) hora,
CASE WHEN ho.dia="Lunes" THEN ho.nombre ELSE '' END Lunes,
CASE WHEN ho.dia="Martes" THEN ho.nombre ELSE '' END Martes,
CASE WHEN ho.dia="Miercoles" THEN ho.nombre ELSE '' END Miercoles,
CASE WHEN ho.dia="Jueves" THEN ho.nombre ELSE '' END Jueves,
CASE WHEN ho.dia="Viernes" THEN ho.nombre ELSE '' END Viernes,
CASE WHEN ho.dia="Sabado" THEN ho.nombre ELSE '' END Sabado FROM (
SELECT h.codigo_hora,h.codigo_docentes,c.nombre,h.dia
FROM horario h
INNER JOIN curso c
ON c.codigo_curso=h.codigo_curso
) ho
INNER JOIN docentes d
ON d.codigo_docentes=ho.codigo_docentes
INNER JOIN hora h
ON h.codigo_hora=ho.codigo_hora
GROUP BY hora
ORDER BY hora ASC
The result obtained when executing the query is the following:
I have several records of my courses assigned to teachers at different times but it does not show me what the class schedule should be like, in several cells it is empty and I do not know what the query would be wrong with, since I have several records. Hopefully you can help me solve this problem.