Need help on sql(mysql query) to check that the selected ‘startdate’ and ‘enddate’ does not have any records in that range.
bellow is my table :
---------------------------------------------------------
| id | start | end |activity|
---------------------------------------------------------
| 1 |2011-10-30 13:00:00 |2011-10-30 14:00:00 | study |
| 2 |2011-10-30 15:00:00 |2011-10-30 16:00:00 | tennis |
| 3 |2011-10-30 17:00:00 |2011-10-30 18:00:00 | golf |
| 4 |2011-10-30 18:00:00 |2011-10-30 19:00:00 | gym |
| 5 |2011-10-30 20:00:00 |2011-10-30 21:00:00 | study |
---------------------------------------------------------
i hope this post will be usefull for others as well.The start and end columns are datetime data type.Basically the query that i am trying to do is to check for activity clashing.
need help .thank you in advance.
Basically you need to see if either the start or the end date of one record is inside another row’s start and end dates. I did it with an
INNER JOIN. You could also do it with aWHERE'clause instead.