本帖最后由 lujunjie1993 于 2011-12-25 15:59:26 编辑

解决方案 »

  1.   


    数据库是下面,字段是id和time,按time降序排序,也要忽略空的那一行。
    id time
    1 1
    2 2
    3 35 5
    6 6
    7 7
    8 8
    9 9
    最终显示如下
    id time
    9  9
    8  8
    7  7
    6  6
    5  5
    3  3
    2  2
    1  1
    就是忽略了空的那一行。
      

  2.   

    select * from 表 order by 字段 的结果中不可以出现空记录在数字记录的中间。
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。   
      

  3.   

    select *
    from tb
    where id is not null
    order by id desc
      

  4.   


    我在帖子的1楼已经说得很明白了。MYsql数据库是
    id time
    1 1
    2 2
    3 35 5
    6 6
    7 7
    8 8
    9 9
    我试了“select * from 表 order by 字段”的确能按字段time降序排序,结果显示
    id time
    9 9
    8 8
    7 7
    6 6
    5 53 3
    2 2
    1 1
    我要显示
    9 9
    8 8
    7 7
    6 6
    5 5
    3 3
    2 2
    1 1
    求代码
      

  5.   


    如果是 create table 表 (id int, time int) 
    那么  select * from  表 order by time desc 是不可能得到你的这个结果的。
      

  6.   

    select *
    from table
    where time  is not null or time!=""
    order by time desc你吧time字段空值去掉就行了。