title: MySQL query for checking event conflict
body: <p>Currently I making a school community site and I got a problem in a part were the administrator post a new event he/she wants check if the event start date and time has no conflict also end date and time before saving it on the database. I tried many queries still i fail to get the exact sql.</p>
  
  <p>I'm using MySQL Server 5 and PHP 5.3. Can any one help me on how to query on the table i mean the right sql string.</p>
  
  <p>Heres the table fields:</p>
  
  <ul>
  <li>event_id => int,</li>
  <li>event_type => enum('school','department'),</li>
  <li>event_title=> text,</li>
  <li>event_details=> longtext, </li>
  <li>event_start=> datetime,</li>
  <li>event_end=> datetime,</li>
  <li>event_added_by=> int,</li>
  <li>event_modified_on=> datetime,</li>
  </ul>
  
  <p>Here is what i have right now:</p>
  
  <pre><code> SELECT *, time(event_start) as start_time, time(event_end) as end_time
   FROM `tbl_events` WHERE ((date(event_start) between '2011-12-9' and
   '2011-12-15') AND (time(event_start) between '00:00:00' and
   '01:00:00')) OR ((date(event_end) between '2011-12-9' and
   '2011-12-15') AND
  </code></pre>