title: MySQL query to filter only expired users from table
body: <p>I'm trying to export af list of subscribers from a database, and while my sql call works, it's missing some logic. My problem is - I want to export users with an expired membership. Some users might have both an expired membership and an active one. I don't want those users on my list. </p>
  
  <p>I'm thinking I need a subquery to filter users with both an expired and an active membership, but I'm not sure how. </p>
  
  <p>Here's my current query:</p>
  
  <pre><code>SELECT 
  jos_users.name,
  jos_users.email,
  jos_users.username,
  jos_payplans_subscription.expiration_date,
  jos_payplans_subscription.status,
  jos_payplans_subscription.total,
  jos_payplans_subscription.subscription_id
  FROM jos_payplans_subscription
  LEFT JOIN jos_users ON jos_payplans_subscription.user_id = jos_users.id
  LEFT JOIN jos_payplans_user ON jos_payplans_user.user_id = jos_users.id
  WHERE (jos_payplans_subscription.expiration_date BETWEEN '2015-09-01 00:00:00' AND '2015-10-31 00:00:00')
  </code></pre>
  
  <p>I'll appreciate any help.</p>
  
  <p>Thanks :-)</p>