我有一个每周不同日子发生的事件列表。 我希望我的查询返回从今天开始按星期几排序的结果。
'Meeting_Day' = Sunday, Monday, Tuesday...
'Day_of_Week' = 1, 2, 3...
SELECT Meeting_Day, Day_of_Week,
Day_of_Week + (Day_of_Week - DAYOFWEEK(NOW())) as x FROM `meetings` ORDER BY x
对于职业选手来说这可能很简单,但我不是职业选手。
答案 0 :(得分:0)
我看了一遍,发现我可以做得很好。
SELECT
*,
If(Day_of_Week < DAYOFWEEK(Now()), (Day_of_Week + 7), Day_of_Week) as SDAY
FROM `meetings`
ORDER BY SDAY