Return data from a N: N table only with foreign keys

0

Good afternoon, I'm a beginner in the SQL language, and I'm wondering how to return the values of the foreign keys in a N: N relationship, for example, return the product name and part name. Thank you in advance.

    
asked by anonymous 31.05.2017 / 18:53

1 answer

0

I believe you can use something like this:

select lp.idProduto,  pd.nome_produto, lp.[idPeças] , pc.[nome_peça]
from [lista_peça] lp inner join produto pd on pd.idProduto = lp.idProduto
inner join [Peças] pc on pc.[idPeças] = lp.[idPeças]

But I strongly advise against using special characters in tables and fields.

Abs.

    
31.05.2017 / 19:20