一个teacher表,一个stu_info表,现在要查询teacher表中每个教师教师名和的学生数
join一下
select t.name, count(s.teacherid) from teachers t join stu_info on t.id = stu_info.teacherid
where s.teacherid=t.name
SELECT tearcher.name, COUNT( student_id )
FROM teacher,stu_info
WHERE stu_info.teacherid = teacher.id