I try to do INNER JOIN in SQL with 4 tables, but, it does not work out.
I use this SQL Query (this works):
SELECT PELICULAS.*, companias.nombre AS nombreCompania
FROM companias INNER JOIN peliculas ON companias.id_compania = peliculas.id_compania
But, when I add another INNER JOIN to enter the table PELICULAS_DIRECTORES
does not work:
SELECT PELICULAS.*, companias.nombre AS nombreCompania,
DIRECTORES.nombre AS nombreDirector
FROM companias INNER JOIN peliculas ON companias.id_compania = peliculas.id_compania
FROM DIRECTORES INNER JOIN PELICULAS_DIRECTORES ON DIRECTORES.id_director = PELICULAS_DIRECTORES.id_director
Diagram:
The first Query works and shows me all the PELICULAS
and I exchange the id_compania
for the nombre
of the table COMPANIAS
.
I want to do the same and get the same, but now, exchanging the id_director
of the table PELICULAS_DIRECTORES
with the nombre
of the table DIRECTORES
. I mean, I want to show at the end the "id", "titulo", "anoLanzamiento", "longitudMinutos", "sinopsis", "nombreCompania", "nombreDirector"
I have tried many combinations and it does not work out, what's wrong with my second Query ?.