title: Select users from one table only if not in another
body: <p>We have two tables:</p>
  
  <p>-- users --</p>
  
  <pre><code>id  name    borrower
  --  ------  --------
  1   Peter   1
  2   John    1
  3   Mark    1
  4   David   0
  </code></pre>
  
  <p>-- lendings --</p>
  
  <pre>id  from  to  amount
  --  ----  --  ------
  1   1     2   100
  </pre>
  
  <p>I need to output users that Peter hasn't lent any money and that are borrowers=1 (excluding Peter from the results), like this:</p>
  
  <pre><code>id  name    borrower
  --  ------  --------
  3   Mark    1
  </code></pre>
  
  <p>Right now I am stuck with this query (doesn't work):</p>
  
  <pre><code>SELECT * 
  FROM `users` u 
  LEFT OUTER JOIN `lendings` l
  ON u.`id` = l.`from`
  WHERE l.`from` is null
  AND u.`id` != 1
  AND u.`borrower` = 1
  </code></pre>
  
  <p><em>This is a simplified example of the actual code to keep the question useful/readable for future readers.</em></p>
  
  <p>Related question: <a href="https://stackoverflow.com/questions/1002728/mysql-select-emails-from-one-table-only-if-not-in-another-table">MySQL: select emails from one table only if not in another table?</a></p>