表结构是怎样的? table teacher id name 1 A 2 Btable student id tid 1 1 2 1 3 1 4 2 5 2 6 2A老师的学生 select * from student where tid=1;B老师的学生 select * from student where tid=2;
或者 select a.*,b.name from student as a left join teacher as b on a.tid = b.id order by a.tid;
table teacher
id name
1 A
2 Btable student
id tid
1 1
2 1
3 1
4 2
5 2
6 2A老师的学生
select * from student where tid=1;B老师的学生
select * from student where tid=2;