You want to create a new table that acts as a link between the subject and teacher, lets call it teacher_subject. The table should have three columns: id, subjectId and teacherId.
To add a subject to the teacher, just insert a new row with the correct subjectId and teacherId.
To get all the subjects that a teacher has, something like this should work:
SELECT subject.*
FROM subject, teacher_subject
WHERE subject.id = teacher_subject.subjectId
AND teacher_subject.teacherId = ?
1
solved please help me PHP and SQL [closed]