I've spent a lot of time searching for an answer to this problem online but I can't seem to come up with anything useful.
I'm pretty new to mySQL so I have a limited enough knowledge.
I have a table events with 6 columns: id, event_name, event_date, event_close_time, event_link, and event_image.
I'm trying to select everything from the database where the event_close_time is < current time if the event is on today and select all the other events in the future.
What I came up with is:
SELECT * FROM `events`
WHERE `event_date` >= 'todays_date'
AND `event_close_time` > 'current_time'
ORDER BY `event_date`
but this doesn't do exactly what I want it to do. It returns all events that are on today or in the future as long as their closing time is earlier then the current time.
It's important that I do it in 1 query because the ORDER BY clause at the end allows me to sort the events into the order I want to use in my web application.
Could anyone point out the adjustments I need to make to get the desired result?
event_close_time > current time? You should not be storing dates and times separately, but use timestamp columns so it's a single comparison. How are the dates/times currently stored?