title: How to get matching pairs of columns in SQL
body: <p>I'm not a SQL expert but say I have a table</p>
  
  <pre><code>ID    Col A   Col B
  id    a1      b1
  id1   a2      b2
  id2   a3      b3
  id3   a4      b4
  id4   a1      b5
  </code></pre>
  
  <p>I  want to get  the ID of all rows which match certain pairs of columns. For example I want rows matching (a1, b1) and (a3, b3) which should return id, id3. </p>
  
  <p>Doing this in linq 2 SQL would be simple using a for loop and some sort of key-value pair collection. 
  However here's the SQL I have so far</p>
  
  <pre><code>    Select * from [MyTable]  WHERE (ColA in ('a1','a3') AND  ColB in ('b1','b3'))
  </code></pre>
  
  <p>this will return a larger subset than I require, specifically it will include non-exact pair matches like row 5 (id4).</p>
  
  <p>I know this requires some sort of self join but I need a bit of help here. </p>