--楼主这样写就挺好的了 可以有几种写法--我这样写比你那样的性能要好点select StudentID, CourseIDfrom student_course a where exists(select 1 from student_course b where a.CourseID=b.CourseID and a.StudentID=b.StudentIDgroup by CourseIDhaving COUNT(1)>30)