title: Complex Unmatched Records Query
body: <p>I have users submitting records to a table called USERS.  To simplify here are the 3 fields: ID, END TIME, VERSION.</p>
  
  <p>I need to identify records that are in the USERS table that and are NOT listed in the MASTER table. However it's possible for a user to submit the same ID more than once.  So then I added to check for different END TIME and version number.  Here is the code I have so far:</p>
  
  <pre><code>SELECT DISTINCT USER.ID, USER.EndTime, USER.Version
  FROM [USER] LEFT JOIN MASTER ON USER.[ID] = MASTER.[ID]
  WHERE (([MASTER.ID] Is Null OR [USER.ENDTIME] &lt;&gt; [MASTER.ENDTIME]));
  </code></pre>
  
  <p>Sample USER TABLE:</p>
  
  <pre><code>|---------------------|------------------|------------------|
  |          ID         |     ENDTIME      |     VERSION      |
  |---------------------|------------------|------------------|
  |          11111      |9/18/18 6:16 PM   |          1       |
  |---------------------|------------------|------------------|
  |          11111      |9/18/18 6:20 PM   |          1       |
  |---------------------|------------------|------------------|
  |          11111      |9/18/18 6:23 PM   |          2       |
  |---------------------|------------------|------------------|
  </code></pre>
  
  <p>Sample MASTER TABLE: (Records I have already imported)</p>
  
  <pre><code>|---------------------|------------------|------------------|
  |          ID         |     ENDTIME      |     VERSION      |
  |---------------------|------------------|------------------|
  |          11111      |9/18/18 6:16 PM   |          1       |
  |---------------------|------------------|------------------|
  |          11111      |9/18/18 6:20 PM   |          1       |
  |---------------------|------------------|------------------|
  </code></pre>
  
  <p>Using the two data sets above and the SQL Statement above <strong>all 3 USER Records are returned</strong> when I only want to see the Version 2 record from 6:23PM</p>
  
  <p>How can I add more criteria to my SQL Statement to ensure all of the following conditions identify the record as new?  </p>
  
  <p>Here are the conditions I need:</p>
  
  <p>1) The ID exists in the user table but not in the master.<br>
  2) The ID exists in both tables, but the end times do not match but the version numbers do. 
  3) The ID exists in both tables, and the version numbers do not match (this would guarantee the end times do not match also).  </p>
  
  <p>I have tried various combinations of AND and OR and cannot get this to work correctly in all scenarios.  Can someone please provide an example of how to accomplish this?</p>