I have a one to many relationship in my database where one event could have multiple dates. I need to find all those events which don’t have any events greater than the current dates (i.e. events which have expired).
I am using the following to select all those events with dates in the future:
SELECT events.id AS id,events.picture,events.name,events.venue,events.city
FROM events,event_dates
WHERE event_dates.start_date >= DATE(NOW())
GROUP BY events.id ORDER BY events.id DESC
I’m not being very smart trying to reverse this, and get events where ALL dates are < DATE(NOW()) or NOT event_dates.start_date >= DATE(NOW())
Which (or neither) is closer to the idea.
Use: