title: SQL Server join on to tables
body: <p>Please help me with the following problem:</p>
  
  <p>SQL Server 2012 database</p>
  
  <p><strong>Table 1 (T1)</strong></p>
  
  <pre><code>*******************************
  | pk_Id | text | fk_t2 | fk_t3|
  *******************************
  |   1   |text1 |    1  |  null|
  *******************************
  |   2   |text2 |    2  |  null|
  *******************************
  |   3   |text3 | null  |  1   |
  *******************************
  |   4   |text1 | null  |  2   |
  *******************************
  </code></pre>
  
  <p><strong>Table 2 (T2)</strong></p>
  
  <pre><code>***************
  | pk_Id | col1| 
  ***************
  |   1   |5285 | 
  ***************
  |   2   |6621 | 
  ***************     
  </code></pre>
  
  <p><strong>Table 3 (T3)</strong></p>
  
  <pre><code>************************
  | pk_Id | col1 | fk_t2 |
  ************************
  |   1   | text1|    1  |
  ************************
  |   2   | text2|    1  |
  ************************
  |   3   | text1|    2  |
  ************************
  </code></pre>
  
  <p>What i need:
  T2.Col1    T3.Col1   T1.Text</p>
  
  <p>Like you see, T2 is related with T3, and both, T2 and T3 are related with T1.
  in T1, column text are stored values for both tables (t2 and t3) when in text column is a value for t2 the fk_t3 is null (i know bad design), and when in text column is a value for t3 the fk_t2 is null.</p>
  
  <p>I know that don’t work:
   (returns nothing)</p>
  
  <pre><code>select t2.col1, t3.col1, t1.text 
  from t2
  inner join t1 on t2.pk=t1.fk_t2
  inner join t2 on t3.pl=t1.fk_t3
  </code></pre>
  
  <p>returns null in t3.col1</p>
  
  <pre><code>select t2.col1, t3.col1, t1.text            
  from t2
  left join t1 on t2.pk = t1.fk_t2
  left join t3 on t3.pl = t1.fk_t3
  </code></pre>
  
  <p>Thank you very much!</p>