title: Counting records from table that appear is one but not other: MYSQL
body: <p>I have a two simple tables </p>
  
  <p><strong>users</strong> </p>
  
  <pre><code>+----+--------+-----------+
  | id | gender | birthdate |
  +----+--------+-----------+
  </code></pre>
  
  <p><strong>userpreference</strong></p>
  
  <pre><code>+----+------------------+-----------------+
  | id | preference value | preference type |
  +----+------------------+-----------------+
  </code></pre>
  
  <p>Question:</p>
  
  <p>I want to query all people who have not listed a specific preference value such as 'shopping'.This includes all people who have not listed any preference types as well so that column could be null, however since userpreference's column 'id' references users as a foreign key, I also want to include in my count all people who don't show up in the second table (user preference)? </p>
  
  <p>Total # of people who do not have preference value 'shopping' as their preference value:</p>
  
  <p>Here is what i have tried:</p>
  
  <pre><code>SELECT
  (
  SELECT COUNT(DISTINCT userpreference.id) FROM userpreference
  WHERE  preferencevalue != 'shopping')
  +
  (
  SELECT COUNT(users.id)
  FROM users
  WHERE users.id NOT IN
  (SELECT userpreference.Id
  FROM userpreference )
  )
  AS'Total'
  </code></pre>