author, id ,title
a  1  title1
a  2  title2
a  3  title3
b  4  title4
c  5  title5我现在要一个结果就是,查找id最小的author不能重复的以id升序的前3名的怎么写如果您是select distinct author,id,title from table order by id asc limit 3select * from table group by author order by id asc limit 3这两种结果就不要贴了,这两个结果都不对

解决方案 »

  1.   

    查找id最小的author不能重复的以id升序的前3名的怎么写 
    =============================================
    这句话貌似理解起来会有歧义,按照你贴出的数据,你想得到什么样的结果?
      

  2.   

    author, id ,title 
    a  1  title1 
    b  4  title4 
    c  5  title5 正确结果应该是这个
      

  3.   

    select * from Table group by author order by id asc limit 0,3
      

  4.   

    您这个肯定不行,这样操作的时候是先执行group by ,然后才执行的order by,所以结果肯定不是想要
      

  5.   

     select * from (select * from table order by id asc) as t1 group by author limit 3;
      

  6.   


    SQL code select * from (select * from table order by id asc) as t1 group by author order by id asc limit 3;这个答案就对了