title: Select rows which are not present in other table
body: <p>I've got two postgresql tables:  </p>
  
  <pre class="lang-none prettyprint-override"><code>table name     column names
  -----------    ------------------------
  login_log      ip | etc.
  ip_location    ip | location | hostname | etc.
  </code></pre>
  
  <p>I want to get every IP address from <code>login_log</code> which doesn't have a row in <code>ip_location</code>.<br>
  I tried this query but it throws a syntax error.</p>
  
  <pre><code>SELECT login_log.ip 
  FROM login_log 
  WHERE NOT EXIST (SELECT ip_location.ip
                   FROM ip_location
                   WHERE login_log.ip = ip_location.ip)
  </code></pre>
  
  <blockquote>
  <pre><code>ERROR: syntax error at or near "SELECT"
  LINE 3: WHERE NOT EXIST (SELECT ip_location.ip`
  </code></pre>
  </blockquote>
  
  <p>I'm also wondering if this query (with adjustments to make it work) is the best performing query for this purpose.</p>