Getting every record in a MySQL table in a specific date range

can someone suggest me a way to display all the records in the MySQL table in a specific date range, and if there are no records in the date, they will be displayed as NULL?

+3
source share
1 answer
SELECT * FROM table_name WHERE date IS NULL OR date BETWEEN 'date1' AND 'date2';

If you want to include date2 in the result, use this

SELECT * FROM table_name WHERE date IS NULL OR date BETWEEN 'date1' AND ADDDATE('date2', INTERVAL 1 DAY);
+2
source

Source: https://habr.com/ru/post/1782227/


All Articles