there is such a structure
id|date 1 |2015-05-26 2 |2015-05-27 ............. I can not figure out how to sort by date so that it displays the current day at the top of the list, and then the rest of the records
there is such a structure
id|date 1 |2015-05-26 2 |2015-05-27 ............. I can not figure out how to sort by date so that it displays the current day at the top of the list, and then the rest of the records
select * from table order by if(`date`=current_date(),0,1), `date` I think you can do it through union all
for example who so
select id,date from table where date=Current_date() union all select id,date from table where date<>Current_date() With comments @Mike
You can make this option
select id,date from ( select id,date, 1 as ord from table where date=Current_date() union all select id,date,2 as ord from table where date<>Current_date() or date is null) order by ord But the @Mike option is more beautiful
Source: https://ru.stackoverflow.com/questions/527700/
All Articles