我有老师和学生老师的桌子
id teacherName classAssigned
1 tea1 1
2 tea2 1
3 tea3 3
4 tea4 2
学生桌有
id name class
1 st1 1
2 st2 1
3 st3 3
4 st4 4
我使用了左连接查询……。作为
SELECT student1.name , teacher1.name
FROM student1 LEFT JOIN teacher1 ON student1.class = teacher1.class where student1.class=1
Student_name Teacher_name
St1 tea1
St1 tea2
St2 tea1
St2 tea2
现在我希望结果为
class TeacherNo Student_no
1 2 2
因为 1 班有两个学生有两个老师 ..我得到的数是 4