How to give a select to only get some mysql record

Asked

Viewed 29 times

0

In the table turma_materia has the following information.

CODIGO   |   MATERIA   |   TURMA
---------------------------------
1        |      1      |    2

In the table Materia has the following information

CODIGO   |   NOME DA MATERIA
  1      |       PORTUGUES
  2      |       MATEMATICA
  3      |       INGLES

I want to take the name of the materials (2-MATEMATICA, 3-INGLES) that is not related in the code class 2 So far you can only get the code below.

SELECT MA.mat_nome, TM.turma_tuma, TM.materia_tuma FROM materia MA 
LEFT JOIN turma_materia TM ON MA.mat_id=TM.materia_tuma
WHERE TM.turma_tuma<>1
  • Additional information: https://answall.com/questions/6441/70

  • SELECT * FROM materia WHERE NOT IN code ( SELECT materia FROM turma_materia WHERE class = 2 )

  • Thank you so much for the help, I get in the following script SELECT * FROM materia WHERE materia.mat_id NOT IN (SELECT turma_materia.materia_tuma FROM turma_materia WHERE turma_materia.turma_tuma=1);

No answers

Browser other questions tagged

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