title: Different between NOT IN and NOT EXISTS in postgres SQL
body: <p>Here's my table.<br>
  <img src="https://i.stack.imgur.com/NJd8b.png" alt="info.student_info table"></p>
  
  <p>When I execute the below query using NOT IN it gives me namal and Ann.</p>
  
  <pre><code>SELECT firstname 
  FROM info.student_info 
  WHERE firstname NOT IN (SELECT firstname 
                          FROM info.student_info 
                          WHERE lastname IS NULL)
  </code></pre>
  
  <p>But when I execute the below query using NOT EXISTS it gives me no rows.</p>
  
  <pre><code>SELECT firstname 
  FROM info.student_info 
  WHERE NOT EXISTS (SELECT firstname 
                    FROM info.student_info 
                    WHERE lastname IS NULL)
  </code></pre>
  
  <p>Why is this? I have researched some areas on NOT IN and NOT EXISTS, but couldn't find an answer for this. </p>