应该会用到存储过程吧.或者你选择数据后,用PHP进行筛选,也可以!

解决方案 »

  1.   

    可能要麻烦一点,试试:
    select num,max(length(num)) as len from table where num like '001%' group by num order by len desc limit 1
      

  2.   

    SELECT num FROM table WHERE num LIKE '001%'GROUP BY length(num) order by length(num) desc limit 1
      

  3.   

    SELECT num FROM table WHERE num LIKE '001%' order by length(num) desc limit 1再问一下,能把group by 去掉吗?
      

  4.   

    group by 
    这个意义重大 
    你最好看看相关文章
    我的理解不完全 怕误导你
    而且 明白 group by 很有意义
      

  5.   

    恩统一楼上,不能去掉group by,意义重大。
    还想继续问下,怎么查找以001开头的长度为六位的数据呢?
    比如
      4   e    001001  
      5   f    001002 
     9   u    001003
      

  6.   

    select num from table where num like '001%' and length(num)=6;
      

  7.   

    select num,length(num) as len from table where num like '001%' order by len desc limit 1这样不行吗?