mysql 第3.10章 查询-union 排序问题 mysql 第3.10章 查询-union 排序问题

2小时前

①、实现功能,活动日期,当天的排在最前,其次是 大于当天的额,最后 是以前的活动 分开,startteim >= 当天的, union starttime< 当天的 问题,分开查,好使,放在一起,大于当天的乱掉

②、原来是:

(select * from v9_activity where starttime>now() and enable=1 order by starttime ASC) UNION ALL (select * from v9_activity where starttime < now() and enable=1 order by starttime DESC)

③、以上排序乱掉。修改为以下:

(SELECT * from (select * from v9_activity where starttime>now() and enable=1 order by starttime ASC) as activity1) UNION ALL (select * from (select * from v9_activity where starttime < now() and enable=1 order by starttime DESC) as activity2)
阅读 4

mysql文章
带到手机上看