Expired member search

Discussion in 'Customization & add-ons' started by kcarey, Mar 27, 2011.

  1. kcarey

    kcarey Member

    Joined:
    Dec 27, 2009
    Messages:
    42
    I need some help with a SQL query to find expired members by a period of time.

    I need to be able to search for members by the date of expired product payment (only one product per member) instead of the date they became members.... because many members have been members for several consecutive years and if I were to query by date member "added" it would not account for these expired members.

    Thanks in advance!

    KCarey
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can use this query :
    Code:
    select *  from  amember_payments p left join amember_members m on p.member_id = m.member_id where p.tm_completed > '2010-01-01' and p.tm_completed < '2011-01-01' and p.completed =1 and p.expire_date < now()
    
    This will return all payments that were completed on past year but expired for now.
  3. kcarey

    kcarey Member

    Joined:
    Dec 27, 2009
    Messages:
    42
    Thanks for the SQL. I need one more step. I want to find the current expired members with an expired payment within the last year.

    The current query found expired payments in the last year, but includes both expired and current active members.


    Thanks again for your help!

    kcarey
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    add this at the end of the query:
    Code:
    select *  from  amember_payments p left join amember_members m on p.member_id = m.member_id where p.tm_completed > '2010-01-01' and p.tm_completed < '2011-01-01' and p.completed =1 and p.expire_date < now() and m.status=2
    
  5. kcarey

    kcarey Member

    Joined:
    Dec 27, 2009
    Messages:
    42
    Thanks for your help!

Share This Page