title: SQL Server Inner Join Where clause
body: <p>My problem is I can not query the matching records.</p>
  
  <p>Queries should do the following:</p>
  
  <pre><code>ID | Name   | Value
  -- | ------ | ------
  1  | Color  | Red
  1  | Color  | Blue
  1  | Color  | Green
  1  | Sizes  | 1cm
  1  | Sizes  | 5cm
  2  | Color  | Yellow
  2  | Color  | Green
  2  | Sizes  | 5cm
  2  | Sizes  | 10cm
  </code></pre>
  
  <p><strong>Query 1:</strong></p>
  
  <ul>
  <li>Color = Red OR Blue<br>
  -AND-</li>
  <li>Sizes = 1cm  </li>
  </ul>
  
  <p>Return matching records (ID=1)</p>
  
  <p><strong>Query 2:</strong></p>
  
  <ul>
  <li>Color = Yellow OR Green<br>
  -AND-  </li>
  <li>Sizes = 5cm</li>
  </ul>
  
  <p>Return matching records (ID=1,2)</p>
  
  <p>My query :</p>
  
  <pre><code>SELECT a.ID, b.Name, c.Value
  FROM table1 a
  INNER JOIN table2 b ON a.Id = b.aId
  INNER JOIN table3 c ON b.ID = c.bId
  WHERE (c.Value = (CASE b.Name WHEN 'Color' THEN 'Red' END)
         OR
         c.Value = (CASE b.Name WHEN 'Color' THEN 'Blue' END)
        )
    AND (c.Value = (CASE b.Name WHEN 'Sizes' THEN '1cm' END))
  </code></pre>
  
  <p>It does not work that way :(</p>
  
  <p>I will be glad if you can help me.</p>