0
I’m not very experienced with SQL language, as I could make a query work this way:
SELECT *,
( SELECT marca.* FROM marca WHERE marca.id = produtos.id ) AS nome_marca
FROM produtos WHERE id = 5
What I want to return is everything *
table produtos
and all *
table marca
guarding in nome_marca
.
If I try to select only 1 field as well ->( SELECT marca.nome FROM marca WHERE marca.id = produtos.id )
the normal wheel code. But it does not run if I try to select all with *
Using the
JOIN
solved my problem, but for didactic reasons as I could for example use + of 1JOIN
like this example:SELECT * FROM produtos
JOIN categoria ON categoria.id = produtos.id,
JOIN marca ON marca.id = produtos.id
WHERE produtos.id = 5
– Anorak
@Anorak, I edited the answer, see if it’s clear..
– rLinhares