日期:2014-05-16  浏览次数:20913 次

mysql忽略空的行降序排序
数据库是
id time
1 1
2 2
3 3

5 5
6 6
7 7
8 8
9 9
请问怎么按字段time降序排序?我试了“select * from 表 order by 字段”的确能按字段time降序排序,结果显示
id time
1 1
2 2
3 3

5 5
6 6
7 7
8 8
9 9
因为有一行是空的,所以显示成这样,请问有什么办法显示的时候忽略了空的那一行,然后按time降序排序,因为某些原因,数据库有些行一定要空的,不能改变,请问怎么忽略空的行然后按time字段降序排序。谢谢

------解决方案--------------------
select *
from table
where time is not null or time!=""
order by time desc

你吧time字段空值去掉就行了。