select username,max(id) as id,max(content) as content
from 你的表
group by username

解决方案 »

  1.   

    select username,max(id) as id,max(content) as content
    from 表 group by username
      

  2.   


    select * 
    from tablename
    where id in ( select max(id) 
                  from tablename 
                  group by username
                )
      

  3.   

    select * from table1 where id in(select max(id)as id from table1 group by username)
      

  4.   

    select *
    from 表 a
    where id = (select max(id) from 表 where username = a.username )
    select *
    from 表 a
    where not exists (select 1 from 表 where username = a.username and id > a.id)