title: Check whether set of rows exists in Production
body: <p>I have two similar tables, one in Production and another in Work in Progress.</p>
  
  <p>I need to copy set of records from Work in Progress to Production. If similar set of records already there in the production, I can't copy.</p>
  
  <p>Instead, I need to get the id of the rows that match.</p>
  
  <p>So, I first check whether the similar set of records are in production before trying to copy.</p>
  
  <p>Here is the example</p>
  
  <p><strong>Criteria in Production table</strong></p>
  
  <pre><code>CriteriaId    CriteriaVal    CriteriaText
  
  1               42               SAM
  
  1               43               Guess
  
  2               324              Sale
  
  2               432              Jones
  
  2               423              Patrick
  
  2               4322             Tiffany
  </code></pre>
  
  <hr>
  
  <p><strong>Criteria in Work In Progress table</strong></p>
  
  <pre><code>CriteriaId    CriteriaVal    CriteriaText
  
  41               42               SAM
  
  41               43               Guess
  
  42               324              Sale
  
  42               432              Jones
  
  42               423              Patrick
  
  42               4322             Tiffany
  
  43               42               SAM
  
  442               324              Sale
  
  442               432              Jones
  
  442               423              Patrick
  
  442               4322             Tiffany
  
  442               3432             SAM
  </code></pre>
  
  <hr>
  
  <p>In the above example criteria id 41 and 42 in the Work in Progress match to criteria id 1 &amp; 2 in production.</p>
  
  <p>So, before I try to copy 41 to prod, when I check whether it exists in prod, I need to get the id 1 is same as 41.</p>
  
  <p>Also, the id 442 in Work in progress is not same as 2, as it has one extra row. I need the counts as well as the values should match exactly.</p>
  
  <p>I am trying to do in a SQL query, but I am not able to do that.</p>
  
  <p>Any pointers on how to match a set of records across tables will be helpful.</p>