我需要获取下一个日期和上一个日期
表结构如下
| auto_id | id | next_date | next_activity |
| 1 | 1 | 22-12-2012 | - |
| 2 | 1 | 25-12-2012 | - |
| 3 | 1 | 26-12-2012 | - |
| 4 | 1 | 28-12-2012 | - |
所以我需要 next_day 和 previous_day next_day = 当前日期之后的 next_date previous_day = current_date 之前的 next_date
(SELECT * FROM `activity` WHERE id = 1 and next_date > CURDATE() order by next_date asc limit 1)
UNION
(SELECT * FROM `activity` WHERE id = 1 and next_date = CURDATE() )
UNION
(SELECT * FROM `activity` WHERE id = 1 and next_date < CURDATE() order by next_date desc limit 1)
ORDER BY next_date desc limit 2
其他方式来做它自己加入表......
有没有办法优化表