0
I would like to know how to insert in a table ids of two other tables. For example, there are 5 tables one is student, which has the following information:
+--------+------------+
| ID_ALU | nome |
+--------+------------+
| 1 | aluno 1 |
| 2 | aluno 2 |
+--------+------------+
class has the following information:
+--------+------------+
| ID_TUR | nome |
+--------+------------+
| 1 | Turma 1 |
| 2 | Turma 2 |
+--------+------------+
In the table materia has the following information:
+--------+------------+
| ID_MAT | nome |
+--------+------------+
| 1 | Materia 1 |
| 2 | Materia 2 |
| 3 | Materia 3 |
+--------+------------+
The student table:
+--------+------------+------------+
| ID | ID_ALU | ID_TUR |
+--------+------------+------------+
| 1 | 1 | 2 |
| 2 | 2 | 1 |
+--------+------------+------------+
In the table, that makes the junction of matter with the class is:
+--------+------------+------------+
| ID | ID_TUR | ID_MAT |
+--------+------------+------------+
| 1 | 1 | 2 |
| 2 | 1 | 3 |
| 3 | 2 | 1 |
+--------+------------+------------+
Now I want SQL to check which class is the student and link the class. Example
+-------+---------+---------+
| ID | ID_ALU | ID_MAT |
+-------+---------+---------+
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 2 | 3 |
+-------+---------+---------+