Events that are not between dates
Posted on 2015-01-25
I have a table with events and each event has a date.
I want to select all events that do not collide with periods of another table.
Events table: EventId int, MyDate date,
Execption table: PeriodId int, StartDate date, EndDate date
PeriodId=1, StartDate='2015-01-02', EndDate='2015-01-08'
The result would be EventId=2, MyDate='2015-01-25'
The reason why eventId=1 is not selected is because it is between startdate and enddate of the exception table.
What is the most efficent way to write a query for this?