日期:2014-05-18  浏览次数:20312 次

我有一张表,请问如何按某字段来排序?
例如有表     table       aaa

字段为id     title     content     type

表中的type有两种情况,会员、非会员。我如何让所有会员信息按时间顺序排在非会员后头?

                                    会员           2007-3-13
                                    会员           2007-3-12
                                    会员           2007-3-12
                                    会员           2007-3-11
                                    会员           2007-3-10
                                  非会员         2007-3-13
                                  非会员         2007-3-11
                                  非会员         2007-3-11
                                  非会员         2007-3-11

------解决方案--------------------
order by type desc
------解决方案--------------------
select * from tb where type = '非会员 ' order by 时间
union all
select * from tb where type = '会员 ' order by 时间

------解决方案--------------------
直接order by不就好了吗?只不过把会员类型放前,日期放后……
反正会员类型就2个,不是asc就素desc
------解决方案--------------------
Select * From aaa Order By (Case type When N '会员 ' Then 0 Else 1 End), 时间字段