title: How do count with inner join and multiple conditions in MySQL
body: <p>I want to a query that counts every time each color is used.</p>
  
  <p>tbl_places is the main table that holds data from several enumeration tables. tbl_places holds the corresponding INT value for the color of specific floors in different buildings. `</p>
  
  <p>tbl_paintcolor is an enumeration table with 2 columns: value and color.</p>
  
  <p>I do not know how to relate the ON clause to the specific column I want to count in tbl_places. </p>
  
  <pre><code>SELECT
    `tbl_paintcolor`.`Color` AS Paint_Color,
    count(`tbl_places`.`blg1floor1_color`) AS Blg1Floor1,
    count(`tbl_places`.`blg1floor2_color`) AS Blg1Floor2,
    count(`tbl_places`.`blg1floor3_color`) AS Blg1Floor3
  FROM `tbl_places` 
  INNER JOIN `tbl_paintcolor` ON (`tbl_places`.`blg1floor1_color`=`tbl_paintcolor`.`Value` OR `tbl_places`.`blg1floor2_color`=`tbl_paintcolor`.`Value`)
  GROUP BY `tbl_paintcolor`.`Color`
  </code></pre>
  
  <p>This query ends up counting the same column more or less. </p>
  
  <p>How can I relate the conditional expressions in the ON clause to the columns I want to count in the SELECT clause?</p>
  
  <p>I would like the query to output a column for each specific floor and each row counts the times that color is found. The output of this query would be structured:</p>
  
  <pre><code>╔════════╦════════════╦════════════╦════════════╗
  ║ Color  ║ Blg1Floor1 ║ Blg1Floor2 ║ Blg1Floor3 ║ etc...
  ╠════════╬════════════╬════════════╬════════════╣
  ║ red    ║     23     ║     23     ║     23     ║
  ║ orange ║     23     ║     23     ║     23     ║
  ║ yellow ║     23     ║     23     ║     23     ║
  ╚════════╩════════════╩════════════╩════════════╝
  </code></pre>
  
  <p>etc   </p>
  
  <p>Thanks you for your time, and apologies if this is unclear, I am very new to SQL.</p>