title: How to count and join between two MySQL tables?
body: <p>I want to write out the number of times a car has been rented and I just cant get it to work, I have two tables. one is called <code>vehicle</code> and the other <code>rental</code>. </p>
  
  <p>In rental is where all the "rentings" go when you book a car and all the vehicles is stored in vehicle. This is the query I made that almost works.</p>
  
  <pre><code>SELECT vehicle.id,COUNT(rental.vid) as rented,IFNULL(rental.vid,0) as nothing, vehicle.make as make, vehicle.model as model, vehicle.regnr as regnr, vehicle.color as color, vehicle.state as state, vehicle.imgurl as img, vehicle.description as description, vehicle.id 
  FROM rental,vehicle 
  WHERE vid = vehicle.id GROUP BY vid
  </code></pre>
  
  <p>and will print out this:</p>
  
  <p><img src="https://i.stack.imgur.com/IppZx.png" alt="The Tables it prints out"></p>
  
  <p>The rest which doesn't have a value (never been rented) isn't there, I have tried a lot of different ways with <code>IFNULL</code> but haven't gotten anywhere.</p>