Here is my table
Events
Start : Datetime
End : Datetime
I'm trying to make sure that a new Event does not overlap any previously entered events. I'll admit my SQL knowledge is novice at best. The following is a select statement that gets me close but I can't figure out how to turn it into a constraint (would I use check?)
SELECT e.*
FROM Events
WHERE Start BETWEEN e.START and e.END
OR End BETWEEN new.START and new.END
OR (Start < e.Start and End > e.End)
I'd imagine if something like that returned anything at all there's overlap.
Edit: updated "sql" statement to cover for a logical failure on my part. It's most likely still poorly formed. I really appreciate all of the help!