SQL Help:
Query
:
SELECT * FROM concursos
LEFT JOIN concursos_categorias ON concursos.id = concursos_categorias.idConcurso
LEFT JOIN categorias_concursos ON concursos_categorias.idCategoria = categorias_concursos.id
WHERE concursos.id = 15
-
concursos
is my table where you have all my contests
-
categorias_concursos
is the table where you have all categories
-
concursos_categorias
is my table where the categories of the contest
in the concursos_categorias
table has the columns idConcurso
and idCategoria
The query she is bringing me the categories of the contest, but I also needed to bring the other categories, not repeating the ones that have this contest.