generate days from date range

后端 未结 29 2423
渐次进展
渐次进展 2020-11-21 05:19

I would like to run a query like

select ... as days where `date` is between \'2010-01-20\' and \'2010-01-24\'

And return data like:

29条回答
  •  不思量自难忘°
    2020-11-21 05:54

    if you will ever need more then a couple days, you need a table.

    Create a date range in mysql

    then,

    select from days.day, count(mytable.field) as fields from days left join mytable on day=date where date between x and y;
    

提交回复
热议问题