title: SQL Server : Join on several tables
body: <p>I need to do a query with the following criteria. I have <code>table1</code>, <code>table2</code> and <code>table3</code>. I need to check that each of <code>table2</code> and <code>table3</code> are subsets of <code>table1</code>.</p>
  
  <p>All of the content of <code>table1</code> should be present in <code>table2</code> and/or <code>table3</code>. All the content of <code>table1</code> could be present in <code>table2</code> alone and sometimes all the content of <code>table1</code> should be present in <code>table3</code> only. Other times <code>table1</code> could be the content of <code>table2</code> and <code>table3</code>. Not everything in <code>table2</code> should match what is in <code>table3</code>.</p>
  
  <p>I want the query to return what is present in <code>table1</code> and not find in <code>table2</code> nor in <code>table3</code>. In addition, it should return what is present in <code>table2</code> and <code>table3</code> and not present in <code>table1</code>.</p>
  
  <p>I have tried the below but it doesnt seem working. Do you have any idea how this could be solved?</p>
  
  <pre><code>Select 
      dr1.col1, dr1.col2 
  from 
      table1 dr1 
  left outer join 
      (Select c.col1, col2 from table2) dr2 on dr1.col1 = dr2.col1 
                                            and dr1.col2 = dr2.col2 
  left outer join 
      (Select col1, col2, col3 from tabl3 ) dr3 on dr1.col1 = dr3.col1 
                                                and dr1.col2 = dr3.col2 
                                                and dr1.col3 = dr3.col3 
  where 
      dr1.col1 is NULL or dr2.col2 is NULL 
  </code></pre>