cys
cys

Reputation: 173

Fetching each records in MySQL table within specific date range

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

Answers (1)

Rendicahya
Rendicahya

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

Related Questions