用GROUP BY 可以分组select * from student where class ='a1' group by age不知道楼主是这个意思吗?

解决方案 »

  1.   

    谢谢seakingx的回复.
    我想我可能没说明白,其实"class"具有不确定因素.我不知道"class"里面可能都有些什么东西.就像我在上面说的一样.class只是打一个比方(当然,我这个比方不太准确).
      

  2.   

    select * from student group by class, age这样可以保证同一个class的同一个年龄的学生排在一起
      

  3.   

    select class, age, COUNT(*) from student group by class, age 
    HAVING COUNT(*) > 1;通过这个查询可以检索出存在同样记录的 CLASS. AGE 组合.然后再使用 SELECT * FROM student WHERE class = ... AND age = ....;
    把他们找出来
      

  4.   

    select * from student a ,student b,where a.age=b.age and a.class=b.class