I have an existing query that I need to modify. The (MS-Access) database has two tables, an Events table which holds information about, well, events, and an EventCalendar table which holds dates, times, and a foreign key reference to an event in the Events table. The query needs to retrieve the next two upcoming featured events to display. To that end, my current query is:
This works well, except for when the next two upcoming performances are for the same event, but on different days; what I want instead is to only retrieve distinct events. So for instance if the next three events in the calendar are:
10/1/10 "The Wizard of Oz"
10/2/10 "The Wizard of Oz"
10/3/10 "Rent"
I don't want to retrieve the second record; I want to retrieve the first and third.
Someone in another forum suggested exploring using MIN() and GROUP BY to achieve the results that I need but I must confess, I don't know how to approach that. I've been experimenting but with no success so far.
I hope I've been clear!
Thanks.
Code:
SELECT StartDate, StartTime, PresentedBy, IsFeatured, VendorEventID, FeaturedImage, FeaturedText
FROM EventCalendar, Events
WHERE EventCalendar.EventID = Events.EventID AND StartDate >= NOW() AND IsFeatured = -1
ORDER BY StartDate
This works well, except for when the next two upcoming performances are for the same event, but on different days; what I want instead is to only retrieve distinct events. So for instance if the next three events in the calendar are:
10/1/10 "The Wizard of Oz"
10/2/10 "The Wizard of Oz"
10/3/10 "Rent"
I don't want to retrieve the second record; I want to retrieve the first and third.
Someone in another forum suggested exploring using MIN() and GROUP BY to achieve the results that I need but I must confess, I don't know how to approach that. I've been experimenting but with no success so far.
I hope I've been clear!
Thanks.