展开全部
有两个思路
1、按照各自的活动状态先排序,插入到临时表,最后再union all所有结32313133353236313431303231363533e58685e5aeb931333363353862果集create temporary table tmp1
select * from tb where 活动状态='筹备中' order by 开始时间;
create temporary table tmp2
select * from tb where 活动状态='进行中' and 开始时间 is not null order by 开始时间;
create temporary table tmp3
select * from tb where 活动状态='进行中' and 开始时间 is null;
create temporary table tmp4
select * from tb where 活动状态='已结束' order by 开始时间 desc;
(select * from tmp1)
union all
(select * from tmp2)
union all
(select * from tmp3)
union all
(select * from tmp4)
2、通过field函数自定义排序
select * from tb order by field(活动状态,'筹备中','进行中','已结束') asc,开始时间 asc;
但这种只能按指定排序,你这种多种排序,有困难。
可以看看上面两种方法结合或许有更好的方法。