title: mysql UNION with COUNT
body: <p>I know there are many posts in similar issues to mine, but I do not seem to be able to find an applicable solution to my case, as below.</p>
  
  <p>I have added null columns so that the number of columns match and I know that I need to have all columns stated in the first select. Therein lies the problem. I do not know how to include a COUNT column in the first select that would correspond to the COUNT in the second select.</p>
  
  <p>Thanks for the assistance.</p>
  
  <p>First select:</p>
  
  <pre><code>SELECT brands.brand_id, 
         brands.brand, 
         models.model_id, 
         models.model, 
         segments.segment_id, 
         segments.segment, 
         versions.version_id, 
         versions.version, 
         versions.places, 
         versions.gearbox, 
         versions.doors, 
         prices.price 
  FROM   versions 
         INNER JOIN models USING (model_id) 
         INNER JOIN segments USING (segment_id) 
         INNER JOIN brands USING (brand_id) 
         INNER JOIN prices USING(version_id) 
  WHERE  price BETWEEN 200001 AND 225000 
         AND brands.active = 'Y' 
         AND models.active = 'Y' 
         AND versions.active = 'Y' 
  </code></pre>
  
  <p>Second select:</p>
  
  <pre><code>SELECT Count(*) AS SafetyItems, 
         version_id, 
         NULL     AS COL3, 
         NULL     AS ....,
         NULL     AS COL12 
  FROM   versiontrim 
         INNER JOIN trims USING(trim_id) 
         INNER JOIN versions USING(version_id) 
         INNER JOIN prices USING(version_id) 
         INNER JOIN models USING (model_id) 
         INNER JOIN brands USING (brand_id) 
  WHERE  trimtype IN( 'sec', 'help' ) 
         AND price BETWEEN 200001 AND 225000 
         AND brands.active = 'Y' 
         AND models.active = 'Y' 
         AND versions.active = 'Y' 
  GROUP  BY version_id 
  </code></pre>
  
  <p>Sample result of first select:</p>
  
  <pre><code> brand_id   brand   model_id model  segment_id  version_id      price   
     58   Renault    11      Megane       4           44         209900
     58   Renault    14      Scenic       5           54         209900
     58   Renault    11      Megane       4           69         200900
     71   Toyota     29      Yaris        2          214         200900
     71   Toyota     30      Auri         4          216         207900
     52   Nissan     58      Pick-up     14          282         209000
     24   Ford       21      Focus        4          290         209000
  </code></pre>
  
  <p>Sample result of second select that I want have appended to above ( after the price column):</p>
  
  <pre><code>SafetyItems     version_id  
     9               44
     7               54
     9               69
    10              214
     6              216
     1              282
    10              290
  </code></pre>