title: PostgreSQL join: delete records present in one table, but not another
body: <p>I have a Drupal website embedding a Flash game.</p>
  
  <p>The registered <strong>website users</strong> are listed in the <strong>drupal_users</strong> table - here the list of those, registered over a week ago:</p>
  
  <pre><code># select uid, created from drupal_users where 
        to_timestamp(created) &lt; (now() - interval '7 days') limit 5;
   uid  |  created
  ------+------------
   9903 | 1300257067
   9904 | 1300259929
   9750 | 1299858284
   9751 | 1299858603
   8083 | 1285514989
  (5 rows)
  </code></pre>
  
  <p>The Flash <strong>game users</strong> are listed in another table - the <strong>pref_users</strong> and have "DE" string prepended to their id:</p>
  
  <pre><code># select id from pref_users where id like 'DE%' limit 5;
     id
  --------
   DE9054
   DE9055
   DE9056
   DE9057
   DE9058
  (5 rows)
  </code></pre>
  
  <p>I would like to get rid of the (probably SPAM robots) users who registered at my website over a week ago, but still haven't played the Flash game. I.e. I'd like to <strong>delete drupal_users records, which are not present in the pref_users table</strong>.</p>
  
  <p>At the same time I'd prefer not to do something like:</p>
  
  <pre><code># delete from drupal_users where 
      to_timestamp(created) &lt; (now() - interval '7 days') and
      'DE'||uid not in (select id from pref_users where id like 'DE%');
  </code></pre>
  
  <p>because I'm not sure, how big the select statement above is allowed to be (maybe there is a limit? I'm using PostgreSQL 8.4.7 and CentOS 5.5/64 bit. Before Drupal7 I was using phpBB3 and sometimes I had seen such kind of SQL-statements fail while deleting old forum posts from phpBB3 admin console).</p>
  
  <p>So my question is, if the statement above can be rewritten as <a href="http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html" rel="nofollow">some kind of SQL-join</a>?</p>