Then turn the ordering on its head, instead of asking which teachers teach which subjects Ask which subject are taught by which teachers.
You have actually got a many to many relationship as many teachers can teach many subjects and many subjects are taught by many teachers. I think.
Having said that I may be wrong as one teacher can only teach one subject at any one time.
David