title: How do I select MySQL records based on results from a related table?
body: <p>I have two tables in this scenario: members and team_members.  The members table is pretty self explanatory.  The team members table stores the member's team information if they are a member of the team.  If there is no row in the team members table that has a member_id of a user, then they are not in a team.  What I want to do is get all the users that are not members of a team.  Should I use left join, inner join, outer join, or just join?  What would this query look like?</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `members` (
    `member_id` int(15) NOT NULL AUTO_INCREMENT,
    `group_id` int(15) NOT NULL,
    `display_name` text NOT NULL,
    `email_address` text NOT NULL,
    `password` text NOT NULL,
    `status` tinyint(1) NOT NULL,
    `activation_code` varchar(16) NOT NULL,
    `date_joined` text NOT NULL,
    PRIMARY KEY (`member_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
  
  CREATE TABLE IF NOT EXISTS `team_members` (
    `team_member_id` int(15) NOT NULL AUTO_INCREMENT,
    `member_id` int(15) NOT NULL,
    `team_id` int(15) NOT NULL,
    `date_joined` text NOT NULL,
    `date_left` text NOT NULL,
    `total_xp` int(15) NOT NULL,
    PRIMARY KEY (`team_member_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
  </code></pre>