select a.id,a.number,a.quantity from table a where id=(select max(id) from table where number=a.number)

解决方案 »

  1.   

    我用了select max(id),ID, number, quantity form tbl_name group by numer
    得出结果如下
    max(id)  id   number quantity
    6        2    A23    33
    8        5    B11    4
    9        4    C11    5
      

  2.   

    嗯.这是一个很经典的问题.
    看看这个帖吧.
    就是你要的解决方案http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6420
      

  3.   

    搞定了,谢谢大家!
    先合并,在拆解
    $thissql="SELECT  SUBSTRING_INDEX(Max(CONCAT_WS(',', id, wlmc) ), ',', 1)  as id, SUBSTRING_INDEX(max(CONCAT_WS(',', id, wlmc) ), ',', -1) as wlmc FROM yxxl where sh='2'  GROUP BY wllb";
      

  4.   

    不敢独享,送给大家http://www.phpe.net/mysql_manual/06-3.html#IDX1187