Mysql: Select all data between two dates -



Mysql: Select all data between two dates -

i have mysql table info connected dates. each row has info , date, this:

2009-06-25 75 2009-07-01 100 2009-07-02 120

i have mysql query select info between 2 dates. query:

select info tbl date between date1 , date2

my problem need rows between date1 , date2 if there no info day.

so query miss dates empty between 2009-06-25 , 2009-07-01.

can in way add together these dates 0 data?

you can utilize concept referred 'calendar tables'. here guide on how create calendar tables in mysql:

-- create infrastructure create table ints (i integer); insert ints values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); -- works 100 days, add together more ints joins more select cal.date, tbl.data ( select '2009-06-25' + interval a.i * 10 + b.i day date ints bring together ints b order a.i * 10 + b.i ) cal left bring together tbl on cal.date = tbl.date cal.date between '2009-06-25' , '2009-07-01';

you might want create table cal instead of subselect.

mysql date between

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -