I have two tables. One is a list of calendar events. The other is a list of dates for those events.
Each event has a unique ID. Each event date has a field referring to the ID of the event it belongs to.
Let's say I have three events, with IDs 1, 2 and 3
Event 1 has two different dates it happens on
Event 2 happens on one date
Event 3 has no dates assigned to it (yet)
I want a list of all the events that have dates, but I don't want an event with multiple dates to be listed multiple times. My query looks like this:
SELECT events.eventid, events.eventname FROM events, eventdates WHERE events.eventid = eventdates.eventid
And my result is basically:
Event 1
Event 1
Event 2
when what I want is
Event 1
Event 2
What I need is a way to select only the events for which there is at least one corresponding event date, but not get multiple returns when there are multiple dates.
Does this make sense? Any thoughts?