title: Excluding certain unique IDs and then grouping the remaining ones
body: <p>So I'm building a car booking website. And there is a cars tables that is like this:</p>
  
  <p>Cars</p>
  
  <ul>
  <li>CarID</li>
  <li>CarModel</li>
  <li>CarMake</li>
  <li>Registration</li>
  </ul>
  
  <p>And also a reservations table like this:</p>
  
  <p>Reservations:</p>
  
  <ul>
  <li>ReservationID </li>
  <li>CarID</li>
  <li>StartDate</li>
  <li>EndDate</li>
  </ul>
  
  <p>So When a user inputs the dates which they would like to book a car I query my reservations table:</p>
  
  <p>If the dates are already in the reservation table I want to get that car ID, and then exclude that car from the list the user is shown, so they can not book it. </p>
  
  <p>My problem is that I have multiple cars in the Database that are the same mode and make but have a different CarID and Registration. </p>
  
  <p>I also group the cars by model so that a user is only shown one car of a certain type. </p>
  
  <pre><code>$carstring = mysql_query("SELECT * FROM cars {$statement} AND deleted = 'no'" GROUP BY CarModel);
  
  $getcars = $carstring;
  while($searchcars = mysql_fetch_array($getcars)) {
  
  
  
     $checkreservations = mysql_query("SELECT * FROM reservations WHERE startDate = '".$sqlcoldate."' and carID = '".$searchcars['carID']."'");
     $thiscar_num_rows = mysql_num_rows($checkreservations);
  </code></pre>
  
  <p>So as you can see at the minute I can tell which cars are taken in the reservations table, and I can echo out true or false from the <code>num_rows</code> </p>
  
  <p>However I think it is the wrong way around because what I want to do is find out which cars by <code>CarID</code> are already taken, and then exclude them from the <code>$getcars</code> query loop that displays all the cars to the user, then group by model.</p>
  
  <p>Can anyone tell me a way to do this, or even a better way to go about it?</p>