一张表三个字段:id name age;
1 张三 10
2 李四
3 王五 11
4 赵六
5 钱七 14
如上面显示的那样,age字段有的是空值
如何让那些age为空的行在最后显示?查询的sql该如何写?不要用order by!
select * from table where age is not null union select * from table where age is null;
这样就行了
不用order by怎么排序
select * from (
select * from table3 where age is not null) t1 full join
(select * from table3 where age is null) t2 on t1.id = t2.id;
只能做到这样了。。。
select * from table3 where age is null
union all
select * from table3 where age is not null