Is it possible to order by date, and if date is not specified to order by time, and if time is bigger than date then it will be first on the list.
For example we got table –
id date time name
1 18.10.2011 18.10.2011 number
2 --------- 19.10.2011 number2
3 --------- 18.10.2011 number3
And it should order something like this –
1 number2
2 number
3 number3
All data is saved in database in time() format, so iif the time and date is equal, it will look at clock. Hope you understood me.
You can attempt to use
ORDER BY CASE. This is untested, but should set you on the right track:Actually, the
ELSE timeis probably unnecessary here. The first two cases should cover it.