title: Select records limited to those with specific value of a second table
body: <p>I have a user table.  I have another table called diagnoses with user id, and with a field called PHgroup that has a bunch of values (1 through 5) for each users.  I want to ONLY select patients who have a value of "1" in the PHgroup and exclude any patient who has any other value other than 1.  When I run this query I get all the records of users with a value of 1 even if they have another PHgroup entry with a value of, say 4.</p>
  
  <pre><code>$query= "SELECT *, users.id as usersid, diagnoses.PHgroup, 
  diagnoses.date_dx FROM users
  inner join diagnoses on diagnoses.user_id = users.id
  where diagnoses.PHgroup = '1' and NOT (diagnoses.PHgroup ='2' and 
  diagnoses.PHgroup ='3'and diagnoses.PHgroup ='4')";
  </code></pre>
  
  <p>How do I select only users with a value of 1 in PHgroup table and not patients who have other values (even if they also have group 1 as well)</p>
  
  <p>To clarify: if a user has an entry with a value of 1 and anotehr entry with a value of 4, I do not want to select that user.
  Only users who have a value of 1 and no other entry with a value other than 1.</p>