title: SQL Check if available between times
body: <p>I'm trying to code a system that let's user book items.
  Items can't be booked twice. So if an item is unavailable i would like to know that by using SQL.</p>
  
  <p>I've got a database with the following fields
  id,item, start (datetime), end (datetime)</p>
  
  <p>A user will try to book an item from "01-01-2016 09:00" till "01-01-2016-22:00". But there is already a row where start is "01-01-2016 11:00" and end is "01-01-2016 16:00". So.. The item isn't available. </p>
  
  <p>How can i do that in SQL?</p>
  
  <p>Now i am using this:</p>
  
  <pre><code>SELECT * FROM `items` WHERE (`start` between '$start' and '$end') AND (`item` = $id)
  </code></pre>
  
  <p>Then i look if the number of rows is higher then 0. If so, the item is unavailable. This works.. but not when the start time is BEFORE the new start time.</p>
  
  <p>I'm hoping that my explanation is clear... Having a hard time dealing with this issue because i can't get the facts straight.</p>