title: SQL: Make colors from color-table searchable
body: <p>I have a database with cards of different colors.</p>
  
  <p>A Card can be "<strong>Colorless</strong>" or one or more colors:
  "<strong>Red</strong>","<strong>Green</strong>","<strong>White</strong>","<strong>Blue</strong>","<strong>Black</strong>"</p>
  
  <p>The <strong>cards</strong> is in a <strong>Card table</strong> with <strong>id, name</strong> and some other card info,</p>
  
  <p>and the <strong>colors</strong> is in a <strong>Color table</strong> with <strong>name</strong>(ex:"Red"), a color <strong>code</strong>(ex:"r") and a color <strong>id</strong></p>
  
  <p>And there are a <strong>Connection table</strong> with <strong>card_id</strong> and <strong>color_id</strong></p>
  
  <p>So <strong>the question is</strong> how do a <strong>make colors searchable</strong>?</p>
  
  <p>I like to be able to find all card that are <strong>"only Red"</strong>,<br>
  aswell as all cards that are <strong>"Red or Blue"</strong>,<br>
  and all cards that are <strong>"Red and Blue"</strong> (and the same for 3,4 and 5 colors!)</p>
  
  <p>There are 30 different combinations of color:</p>
  
  <pre><code>//000001//000010//000011//000100//000101//000110//000111
  //001000//001001//001010//001011//001100//001101//001111
  //010000//010001//010010//010011//010100//010101//010110
  //010111//011000//011001//011010//011011//011100//011101
  //011111
  //100000 (Colorless)
  </code></pre>
  
  <p>I have found out that this is posible with <strong>UNION</strong> but<br>
  one have to make all 30 different combinations and then UNION them all together!</p>
  
  <pre><code>SELECT 
  c.id
  'false' AS Colors,
  'true' AS Red, 
  'false' AS Blue
  'false' AS Green
  'false' AS White
  'false' AS Black
  'false' AS Colorless
  FROM cards_data AS c
  INNER JOIN con_cards_colors AS ccc_red ON c.id = ccc_red.cards_id
  INNER JOIN colors AS co_red ON co_red.id = ccc_red.colors_id
  WHERE
      co_red.name = "Red"
  
  Union
  (...)
  </code></pre>
  
  <p>This dosnt seem like a good solution!</p>
  
  <p><strong>So any idears will be appreciated?</strong></p>
  
  <p>(Optimal I like some kind of a SQL View..)</p>