-1
Well, I’ve got the tables professores
, materias
, turmas
. To make it easier and simpler (because all I need is that data), say that there are the following data:
turmas (2)
+-------+----------+---------+
| id | codigo | nome |
+-------+----------+---------+
| 10 | 5 | TURMA X |
| 20 | 6 | TURMA Y |
+-------+----------+---------+
materias (3)
+-------+-----------+---------+
| id | nome | turma |
+-------+-----------+---------+
| 123 | MATERIA X | 5 |
| 124 | MATERIA Y | 5 |
| 125 | MATERIA Z | 6 |
+-------+-----------+---------+
professor (1)
+-------+-----------+----------+
| id | nome | materias |
+-------+-----------+----------+
| 1 | Carlos | 123, 125 |
+-------+-----------+----------+
I need to create a SELECT that takes the CODE and NAME data from the CLASSES table based on what is inserted in MATERIALS from the PROFESSOR table. These materials are separated by commas. Therefore, the query must pass through these 3 tables, taking the information from professor of materials., searching separated by a comma materias.class, to then reach the class code and name.classes.
It’s been a long time since I’ve programmed, anyone who can help, I appreciate!
Let’s see if I understand correctly: on the table
professores
the fieldmaterias
is a single field with the various subjects of the teacher separated by comma? If that’s right your database is very poorly built, take a look at normalization.– anonimo