I'm trying to figure out how to write a MySQL query that will return the closest 3 events in terms of date.
This is my table:
EVENT_ID EVENT_NAME EVENT_START_DATE(DATETIME)
1 test 2011-06-01 23:00:00
2 test2 2011-06-03 23:00:00
3 test3 2011-07-01 23:00:00
4 test4 2011-08-09 23:00:00
5 test5 2011-06-02 23:00:00
6 test6 2011-04-20 23:00:00
So the query result should be for ID's 1,2,5 as they are the closest to occur in comparison to the current date..
EDIT: query should find only future events.
question from:https://stackoverflow.com/questions/6186962/sql-query-to-show-nearest-date