title: SQL query to exclude certain values from table
body: <p><img src="https://i.stack.imgur.com/IGeE2.png" alt="enter image description here"></p>
  
  <p>Hi everyone I am in the process of building a room allocating system that checks if a room is available on a given date. There are about 20 unique room ids and I've just included as snippet of several above. </p>
  
  <p>So for example if the user types in the date of 2012-01-01 I would want the <strong>room_id</strong> of 1 to be excluded from the results because as seen above it has been already booked for that date.</p>
  
  <p>In a sense any match found between the user's in-putted date should cause the entire list of corresponding room_id's to be excluded from the list.</p>
  
  <p>I used the below SQL query:</p>
  
  <pre><code>SELECT DISTINCT room_id
  FROM room_booking
  WHERE date_booked&lt;&gt;'$date'
  </code></pre>
  
  <p>Unfortunately it doesn't work because although it excludes the result for a single row, it includes the rest of the results for a given <em>room_id</em>? </p>