I need to make a SELECT
into two tables and merge the results.
My tables are "class_tracks" and "progress_tracks". In the table "courses_aula" I have all the classes of a course. In the table "cursos_progresso" I have registration only if the client started (finishing or not) the class. That is, I need you to list all the classes in course X and display the status that is in the table "progress_tracks". If the record does not exist it should return NULL
, but I am only able to merge the matching results into the two tables.
My Query is:
SELECT a.id, a.aula, p.status
FROM cursos_aulas a
LEFT JOIN cursos_progresso p ON p.id_aula=a.id
WHERE a.id_curso='$idCurso' AND p.cpfcnpj='$cpfcnpj'
ORDER BY a.sequencia
Does anyone know what I might be doing wrong?