title: Updating a Bulky mySQL query for active users
body: <p>I have a long form PHP function to loop over all my users and test their activity status. It's slow and takes multiple operations... this SQL operation is much faster but right now but my counts mismatch with each other.</p>
  
  <p>I need to update this mySQL query to do what it does with 1 addition and 1 adjustment. So that it mimics the exact action/function of testing user activity.</p>
  
  <pre><code>"SELECT DISTINCT last.user_id
  FROM ss_usermeta as last
  JOIN ss_usermeta as next on last.user_id = next.user_id
  WHERE last.meta_key = 'last_trans_date' and last.meta_value &lt;= CURDATE()
  and next.meta_key = 'next_recurring_date' and next.meta_value + INTERVAL 9 day &gt;= CURDATE()";
  </code></pre>
  
  <ul>
  <li>Check each users meta_key for 'll_customer_id' and make sure its not empty.</li>
  <li>Change the comparator of the next_recurring_date from the current date to the current date + 9 days.</li>
  </ul>