I am writing a php function in which i am taking 2 parameters ,
I also want if both dates are Null then this function should return the all rows
Here is my mysql query
select COUNT(*) from demo_meeting where meeting_datetime > "2013-01-01 OR NULL" and meeting_datetime < "2013-09-10 OR NULL";
THis query is working properly if both dates are available if i am using both date as NULL it is returning the Zero rows .
PLease tell me how can i improve this query so that if both date are NUll then it could return the all meetings
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `demo_meeting` ADD INDEX `demo_meeting_idx_meeting_datetime` (`meeting_datetime`);
SELECT COUNT(*) FROM demo_meeting WHERE demo_meeting.meeting_datetime > '2013-01-01 OR NULL' AND demo_meeting.meeting_datetime < '2013-09-10 OR NULL'