SELECT id, city_id, title, introduce, tags, avg_price, promotion, meeting_info, start_time, end_time, memo, registor_num,if(unix_timestamp() < start_time, 2, if(start_time < unix_timestamp() <= end_time, 3, 1)) as orderBy FROM `group_visit_house` `t` WHERE del_flag = 0 and is_show = 1 and city_id = 3 and start_time < unix_timestamp() and end_time > unix_timestamp() ORDER BY orderBy DESC, if(orderBy=3,"start_time DESC",if(orderBy=2, "start_time ASC", "end_time DESC"))
orderBy别名,当数据库时间小于start_time时候orderBy为1,在start_time和end_time之间时候为3,其余情况为1,然后根据orderBy排序,排序后再分别根据orderBy分别排序