select classid,info from (select classid,min(info) as info from t2 group by classid) a inner join (select classid,max(info) as info from t2 group by classid) b on a.classid=b.classid and a.info<>b.info

解决方案 »

  1.   

    来了写一句吧
    select classid,info from t2 where classid=A order by ID union ... limit 2不过要知道T1的所有值现在想想SQL是否有while(...)语句??
      

  2.   

    mysql版本是4.0,不能子查询啊huarc(华客) 
    您能把完整的SQL写下吗?另外:这种情况是不是mysql4.0无法完成的?
      

  3.   


    我用的是MYSQL4。0以上的,我的本地机就成,但公司的服务器就不成
      

  4.   

    那如果支持子查询的话这个SQL该怎么写?
      

  5.   

    select classid,a.info,b.info from (select classid,min(info) as info from t2 group by classid) a inner join (select classid,max(info) as info from t2 group by classid) b on a.classid=b.classid and a.info<>b.info更正一下