title: SQL need to separate results by "before" and "after" date using a third table
body: <p>Here's the situation: I have tables where relevant rows are...</p>
  
  <pre><code>contact
  -- contact_id
  
  event
  -- event_id
  -- event_group_id
  
  groups
  -- group_id
  
  groupmember
  -- group_id
  -- contact_id
  
  attendance
  -- contact_id
  -- group_id
  -- event_id
  -- timestamp (current timestamp)
  
  
  
  //Query the database for group members 
  $result = mysql_query(
  "SELECT contact.contact_id, contact.first, contact.last, 
    contact.home_phone, contact.mobile_phone, contact.email, contact.address, 
    contact.city, contact.state, contact.zip 
  FROM contact 
  INNER JOIN groupmember ON contact.contact_id = groupmember.contact_id 
  WHERE groupmember.group_id = '$groupid' 
  ORDER BY last
      "); 
  </code></pre>
  
  <p>What I would like to do is trim those results by checking the table named "attendance" and only showing those results that have attended an event sponsored by the group '$group' in the last 6 months. </p>
  
  <p>Then, after those results are shown, to generate another list at the bottom of the page showing those contacts who are 'inactive' because the last time they attended an event sponsored by '$group' was over 6 months ago. 
  I would assume another WHERE statement would have to be appended with an INNER JOIN with the attendance table, but I'm not even sure that can be done.  </p>
  
  <p>Any ideas how I can accomplish this?</p>