title: Selecting rows based on values in other table
body: <p>Probably a beginner-question. I can't select a row based on criteria from other table. Should be simple, but I'm missing something.</p>
  
  <p>I have two tables:</p>
  
  <p><strong>T1</strong>  </p>
  
  <pre><code>X    C  
  3    a  
  4    a  
  41   b
  </code></pre>
  
  <p>and</p>
  
  <p><strong>T2</strong>  </p>
  
  <pre><code>A    B    C    D  
  1    5    a   22  
  7   11    a   27  
  35  49    b   29 
  </code></pre>
  
  <p>I want to add the column D to T1, where X is between A and B in T2, and C=C. So the resulting table should look like this:</p>
  
  <p><strong>T1b</strong>  </p>
  
  <pre><code>X    C    D  
  3    a    22  
  4    a    22  
  41   b    29  
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>/Chris</p>