Selecting Non-existent Data With MySQL

后端 未结 3 1883
攒了一身酷
攒了一身酷 2020-12-12 06:30

I\'m trying to select data between two date range. However not all data are being inserted daily. Below is sample of the table:

mysql> SELECT * FROM atten         


        
3条回答
  •  一整个雨季
    2020-12-12 06:38

    MySQL cannot generate data that isn't there. If you want non-existent dates, you'll need to have a temporary table that contains the full date range you join against. Another alternative is to maintain a server-side variable and do some date math for each row, which is ugly

    select @dateval := '2012-07-02';
    SELECT @dateval := @dateval + INTERVAL 1 DAY from ...
    

提交回复
热议问题