3
I have 4 tables they are already with Foreign key.
aluno:
id
matricula
username
curso_id // referencia a id_cursos da tabela cursos, coluna id_cursos.
cursos:
id_cursos
nome_cursos
modulos:
id_modulos
nome_modulos
cursos_id //faz referencia a tabela cursos, coluna id_cursos.
materias:
id_materias
nome_materias
modulos_id // faz referencia a tabela modulos, coluna id_modulos.
How do I Join to return the related columns of these tables ? if I run the code:
SELECT cursos.nome_curso, aluno.username
FROM aluno JOIN cursos on cursos.id_cursos = aluno.curso_id;
will return only the relationship of these two tables, but the 4 are related as I would do this ?
That was the best question and answer (from @Bacco) on the subject What is the difference between INNER JOIN and OUTER JOIN?, explains in detail each type of JOIN with examples, for sure if you read will see which one fits your problem.
– Guilherme Nascimento