title: Delete all not referenced (by foreign key) records from a table in mysql
body: <p>I have a address table which is referenced from 6 other tables (sometimes multiple tables). Some of those tables have around half a million records (and the address table around 750000 records). I want to have a periodical query running which deletes all records that are not referenced from any of the tables.</p>
  
  <p>The following sub-queries is not a option, because the query never finishes - the scope is too big.</p>
  
  <pre><code>delete from address where address_id not in (select ...)
  and not in (select ...) and not in (select ...) ...
  </code></pre>
  
  <p>What I was hoping was that I could use the foreign key constraint and I could simply delete all records for which the foreign key constraint does not stop me (because there is no reference to the table). I could not find a way to do this (or is there?). Anybody another good idea to tackle this problem?</p>