I'm a little unsure of how to build the following query for a MySQL database.
My table has two int fields, startDate and endDate that hold UNIX timestamps. endDate can be NULL which implies no ending date.
I want to get all records for which the current timestamp falls within the range.
In the case that endDate has a value, I can do:
SELECT * FROM table WHERE startDate < NOW() AND endDate > NOW()
and in the case that endDate is NULL, I can do:
SELECT * FROM table WHEREstartDate< NOW()
My question is, how I can combine the above two queries into one, single conditional query?