title: SQL query to fetch unmatched records from two tables
body: <p>I have two tables <code>userprofile</code> and <code>deviceid</code>.</p>
  
  <ul>
  <li><code>userprofile</code> contains columns <code>username</code>, <code>studentname</code></li>
  <li><code>deviceid</code> contains columns <code>username</code>, <code>device id</code></li>
  </ul>
  
  <p>I want to fetch username records from <code>userprofile</code> which are not in <code>deviceid</code> (<code>username</code>).</p>
  
  <p>My query is</p>
  
  <pre><code>SELECT 
      userprofile.username, userprofile.studentname 
  FROM 
      userprofile
  LEFT JOIN 
      deviceid ON deviceid.username = userprofile.username
  WHERE 
      deviceid.username IS NULL;
  </code></pre>
  
  <p>It's not fetching any values.</p>