title: SQL Server : using SELECT in NOT IN WHERE Clause
body: <p>I've been using this query statement ever since. I wonder why this does not work on SQL Server 2008 R2.</p>
  
  <pre><code>SELECT
      UserName
  FROM 
      Users 
  WHERE 
      UserName NOT IN (SELECT UserName FROM UserTableT2)
  </code></pre>
  
  <p>The codes does not return any data. Goal is select all <code>UserName</code> in <code>Users</code> table which do not belong to <code>UserTableT2</code>.</p>
  
  <p>EDIT:</p>
  
  <p>Here's the actual query
  <a href="https://i.stack.imgur.com/pp8K4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pp8K4.png" alt="enter image description here"></a></p>
  
  <p>Update using @Tim Schelmter's query:
  <a href="https://i.stack.imgur.com/PkXms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PkXms.png" alt="enter image description here"></a></p>
  
  <p>Update :
  <a href="https://i.stack.imgur.com/XbF9a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XbF9a.png" alt="enter image description here"></a></p>
  
  <p>Update: 
  <a href="https://i.stack.imgur.com/SdMYG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SdMYG.png" alt="enter image description here"></a>
  Thank you!</p>