title: Check user status as part of SQL query
body: <p>I'm running an SQL query that shows a collection of vouchers, in order of how many times the voucher has been used down to £0 in another database.</p>
  
  <p>As a final step though, i'd like to check that the 'user.state' of the corresponding 'voucher_credits.user_id' is still 'active', how can I add this in?</p>
  
  <pre><code>SELECT vouchers.code, count(voucher_credits.voucher_id) as Activated
      FROM vouchers, voucher_credits, users
      WHERE vouchers.code LIKE '%sentme%' 
          AND vouchers.id = voucher_credits.voucher_id
          AND voucher_credits.remaining_credit = 0
          AND *** the user.state of voucher_credits.user is 'active' ***
      GROUP by vouchers.code
      ORDER by count(voucher_credits.voucher_id) DESC
      LIMIT 50
  </code></pre>