title: MSSQL - Compare data from 1 table to multiple tables
body: <p>I need to do a comparison from one table (which is a CRM inventory) to 4 other tables (which are webserver inventories).  Currently I am using the following query, but I am getting duplicates and false positives due to the fact it is rechecking the first table against each other table and simply outputting the results every time then displaying them all together:</p>
  
  <pre><code>SELECT sc.Client,
         ws.[Host Header],
         ws.[IP Address],
         ws.[Status]
  FROM   sc
         FULL JOIN ws
                ON sc.Urls = ws.[Host Header]
  WHERE  sc.Client IS NULL
          OR ws.[Host Header] IS NULL
          OR sc.Urls &lt;&gt; ws.[Host Header]
  UNION
  SELECT sc.Client,
         ws2.[Host Header],
         ws2.[IP Address],
         ws2.[Status]
  FROM   sc
         FULL JOIN ws2
                ON sc.Urls = ws2.[Host Header]
  WHERE  sc.Client IS NULL
          OR ws2.[Host Header] IS NULL
          OR sc.Urls &lt;&gt; ws2.[Host Header]
  UNION
  SELECT sc.Client,
         ws3.[Host Header],
         ws3.[IP Address],
         ws3.[Status]
  FROM   sc
         FULL JOIN ws3
                ON sc.Urls = ws3.[Host Header]
  WHERE  sc.Client IS NULL
          OR ws3.[Host Header] IS NULL
          OR sc.Urls &lt;&gt; ws3.[Host Header]
  UNION
  SELECT sc.Client,
         ws4.[Host Header],
         ws4.[IP Address],
         ws4.[Status]
  FROM   sc
         FULL JOIN ws4
                ON sc.Urls = ws4.[Host Header]
  WHERE  sc.Client IS NULL
          OR ws4.[Host Header] IS NULL
          OR sc.Urls &lt;&gt; ws4.[Host Header] 
  </code></pre>
  
  <p>Can someone point me in the right direction?  I want to return only the distinct results from each of the tables that are null or mismatching in the sc.Client and ws.[Host Header] fields and there are no duplicates between the 4 webserver tables.</p>
  
  <p>Thanks!</p>