Can we generate auto date in SQL, if date is not exit in table with zero value in table?
I have a table with the name of final_registration where I am storing registration data, Following is my table:
*---------------------------------------------------------------*
| id | event_id | Name | booking_date | ticket_status |
*---------------------------------------------------------------*
| 1 | 101 | Sandeep | 2018-11-30 15:43:24 | active |
| 2 | 101 | Jagveer | 2018-12-01 18:44:20 | active |
| 3 | 101 | Sudhir | 2018-12-01 20:34:20 | active |
| 4 | 101 | Aman | 2018-12-03 18:44:20 | active |
*---------------------------------------------------------------*
I am runing following query for output:
SELECT COUNT(id), booking_date
FROM final_registration
WHERE `event_id` = 101
AND `booking_date` >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
AND ticket_status='active'
GROUP BY DATE_FORMAT(`booking_date`, '%d-%b');
The output is showing:
*--------------------------*
| count(id) | booking_date |
*--------------------------*
| 2 | 2018-12-01 |
| 1 | 2018-12-03 |
*--------------------------*
But I do not want this, I want the following output from the query:
*--------------------------*
| count(id) | booking_date |
*--------------------------*
| 2 | 2018-12-01 |
| 0 | 2018-12-02 |
| 1 | 2018-12-03 |
| 0 | 2018-12-04 |
*--------------------------*
Note Today is 4th Dec-2018 so here, I am using the current date.
so how can I generate auto date if there is no date in my table values?