Reputation: 173
can anyone suggest me way to display all records in MySQL table within a specific date range, and if no records available on the date, it will still display as NULL?
Upvotes: 3
Views: 931
Reputation: 4285
SELECT * FROM table_name WHERE date IS NULL OR date BETWEEN 'date1' AND 'date2';
If you wish to include date2 with the result, use this
SELECT * FROM table_name WHERE date IS NULL OR date BETWEEN 'date1' AND ADDDATE('date2', INTERVAL 1 DAY);
Upvotes: 2