I am trying to write a query to skip the date if it is not selected in the form. So far I got this:
SELECT SQL_CALC_FOUND_ROWS id, dateTime FROM Message WHERE IFNULL(dateTime, '') < '' AND IFNULL(dateTime, '') > '' AND IFNULL(body, '') LIKE '%%';
If I run for e.g.: IFNULL(body, '') LIKE '%%'; using LIKE it is working fine it returns the expected results. But if I use < or > and if the date is empty it does not return me any results.
My question is how can I skip searching for a date if it is empty?
I think you want this: