【发布时间】:2016-05-13 23:34:37
【问题描述】:
我有一张桌子
... | reservation_from | reservation_to | ...
1 | 2016-05-13 10:00:00 | 2016-05-21 10:00:00 | ...
2 | 2016-05-13 20:00:00 | 2016-06-29 14:00:00 | ...
3 | 2016-05-01 10:00:00 | 2016-05-13 16:00:00 | ...
现在我必须订购并预订离今天最近的一天。
例如现在是 2016-05-13,所以无论预订是要开始还是要结束,我都必须得到最接近当前时间的结果。我想这样订购
... | reservation_from | reservation_to | ...
1 | 2016-05-13 10:00:00 | 2016-05-21 10:00:00 | ...
2 | 2016-05-01 10:00:00 | 2016-05-13 16:00:00 | ...
3 | 2016-05-13 20:00:00 | 2016-06-29 14:00:00 | ...
如您所见,第二个结果 reservation_from 是 05-01 但它的 reservation_to 小于第三个 reservation_from
我不知道我是否清楚这个问题,如果没有,请评论它我应该详细说明什么。
【问题讨论】:
-
除非你是时间旅行者,否则今天是 2016-05-13 ;)
-
您需要解释您使用的最接近今天的逻辑,以及如何处理决胜局。
-
@mitkosoft 我已经看过这个答案和很多其他人,但我没有得到它:/
-
我用更多解释编辑了我的问题。我的意思是我需要两列 reservation_from 和 reservation_to 例如在 DESC 和最接近今天的功能订购