I have a MySQL table named 'activity' that contains activity data. The important columns are 'start_time' and 'end_time' which contain string (YYYY-MM-DD) to represent when the activity starts and ends.
I want to get some records at one time.Kind of like paging.The problem is I need to sort the data. Sorting rules:
1:data which current time between start_time and end_time row first
2:data which current time before start_time second
3:data which current time after end_time last
Events:
--------------------------------
ID | START_TIME | END_TIME|
--------------------------------
1 | 2013-06-14 | 2013-06-14 |
2 | 2013-07-01 | 2013-07-10 |
3 | 2013-07-30 | 2013-07-31 |
4 | 2013-06-15 | 2013-08-21 |
5 | 2013-06-22 | 2013-06-25 |
------------------------------
Don't you know how to do that? Any suggestions?
Thanks! Example: Today is 2013-06-23.I need data like this:
--------------------------------
ID | START_TIME | END_TIME|
--------------------------------
4 | 2013-06-15 | 2013-08-21 |
5 | 2013-06-22 | 2013-06-25 |
2 | 2013-07-01 | 2013-07-10 |
3 | 2013-07-30 | 2013-07-31 |
1 | 2013-06-14 | 2013-06-14 |
------------------------------