I have 3 tables T1,T2 and T3. Table T1 contains 2 columns (key,class/student). The column class/student contains both classes and students, for example: 'english', 'math', 'mark', 'tom'... Table T2 contains 2 columns (class,student). Each class have more than one student in it, and these 2 columns use the keys from T1. In Table T3 I want to insert a specific class with its student(s) - class(es) into column A and student(s) into column B. Knowing that these columns use the keys from T1 table I've tried this but it returns same specific class with its students multiple times:
INSERT INTO T3 (A,B)
SELECT m.class, m.student
FROM T1 b,T2 m
WHERE m.class = (SELECT key FROM T1 WHERE class/student='English')
AND b.KEY = m.student;
the result i get: 1 is id of class english ,10 is id of student mark, 11 is id of student tom
table T1:
Table T2:



JOINS, there is plenty of information online that can be a great place to start. You need to understand these concepts instead of coming here looking for an answer. Better to teach a man to fish than to give him a fish, even better if he can learn to teach himself how to fish.