How do I make a select that returns a field from a table through another table?

Asked

Viewed 24 times

0

Here’s the thing, I want to select in the model table that shows, in addition to the fields shown in SELECT, the field lamina_tubo_primaria.DESC_PRIMARIA also.

But the countryside DESC_PRIMARIA only relates to the model table by means of the table lamina_tubo_secundaria.

SELECT m.id_modelo,
 m.descricao,
 f.nome fabricante,
 o.nome optico

FROM
 modelo m

LEFT JOIN
 fabricante f ON f.id_fabricante = m.id_fabricante
 
LEFT JOIN
 optico o ON o.id_optico = m.id_optico;

inserir a descrição da imagem aqui

  • ... FROM modelo m INNER JOIN lamina_tubo_secundaria s ON (m.id_lamina_tubo_secundaria = s.id_lamina_tubo_secundaria) INNER JOIN lamina_tubo_primaria p ON (s.id_lamina_tubo_primaria = p.id_lamina_tubo_primaria). Since you didn’t post the other tables involved I assume you know how to do.

  • Thank you, that’s right

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.