title: sql select records that don't have relation in a second table
body: <p>I am trying to run an SQL query in phpMyAdmin in a MySQL database in order to get records that do not have corresponding records in another table.</p>
  
  <p>E.g.</p>
  
  <pre><code>**album**
  id, name
  
  **track**
  id, album_id, name
  </code></pre>
  
  <p>I need all album records that do not have relative track records.</p>
  
  <p>I have tried </p>
  
  <pre><code>SELECT album.id
  from album 
  WHERE album.id NOT IN (
    SELECT track.album_id 
    FROM track 
    WHERE 1
    GROUP BY track.album_id
  )
  </code></pre>
  
  <p>But unfortunately this crashes the MySQL service</p>
  
  <p>I have also tried </p>
  
  <pre><code>SELECT a.id FROM album a
  INNER JOIN track t
  ON a.id = t.album_id
  WHERE t.id IS NULL
  </code></pre>
  
  <p>but this doesn't work as expected (returns no results)</p>