I'm working on a calendar like feature to a project of mine.
I have a table like the following:
ID | Title |Where |tri| Start | End | tro
______________________________________________________________________
"4"|"Planingfrenzy" |"Street 8"|"0"|"1395835200"|"1395846000"|"1"
"5"|"Other meeting" |"Road 8" |"0"|"1395140400"|"1395158400"|"1"
"6"|"Third meeting" |"Lane 8" |"0"|"1395819000"|"1395824400"|"1"
"8"|"Weekend at cyprus"|"Cyprus" |"0"|"1395928800"|"1396162800"|"1"
I have a problem selecting alla events that happens in one day. I tried the following two queries, but they only return those events thats start and end at the same day.
/*
Start is a unixtimestamp for the beginning of the day
End is a unixtimestamp for the end of the day
*/
//This Returns to many events since all events that ends before the end timestamp is a match etc.
SELECT * FROM events WHERE (start > ? OR end<?)
//This matches all events that start and end at the same day. But a multi day event like "Weekend at cyprus" isn't returned since it is out of range
SELECT * FROM events WHERE (start > ? AND end<?)
Is there some way in MySQL or PHP to match if start/end range "touches" in the queried timestamp range?