title: Counts for lots of boolean fields in one sql query?
body: <p>Not sure exactly how to explain this but Imaging you have a table with lots of boolean fields like this......</p>
  
  <p>Table: Cars</p>
  
  <p>Columns:</p>
  
  <blockquote>
    <p>Automatic: boolean</p>
    
    <p>Silver: boolean</p>
    
    <p>American: boolean</p>
    
    <p>Noisy: boolean</p>
    
    <p>Smelly: boolean</p>
    
    <p>fast: boolean</p>
  </blockquote>
  
  <p>(silly fields and most of them wouldn't be bools in reality but just an example)</p>
  
  <p>What I need to do is produce a list of these fields with a number of search results next to each one, so if there were 100 silver cars in the database and 57 American cars the list might look a bit like this...</p>
  
  <blockquote>
    <p>Automatic: (150)</p>
    
    <p>Silver (100)</p>
    
    <p>American (57)</p>
    
    <p>Noisy (120)</p>
    
    <p>Smelly (124)</p>
    
    <p>fast (45)</p>
  </blockquote>
  
  <p>So, it's basically like a list of filters, if the user clicks "silver" they will narrow the search down to only show silver cars and they know they will get 100 results. The numbers next to all the other filters will then decrease because we've filtered out all cars that aren't silver.</p>
  
  <p>Counting the occurences of one field would be easy....</p>
  
  <p>SELECT COUNT(*) FROM CARS WHERE Automatic = true;</p>
  
  <p>... would give me the first row for example. But I don't want to have to do one SQL statement for each filter as there could be over 30 of them. I've seen plenty of sites do this so it must be easier than I think it is.</p>
  
  <p>Any help would really be appreciated :)</p>
  
  <p>Jon</p>