title: mysql inner join with having
body: <p>My tables are:</p>
  
  <pre><code>mysql&gt; select * from professor;
      +-------+--------+--------+--------+------+
      | empid | name   | status | salary | age  |
      +-------+--------+--------+--------+------+
      |     1 | Arun   |      1 |   2000 |   23 |
      |     2 | Benoy  |      0 |   3000 |   25 |
      |     3 | Chacko |      1 |   1000 |   36 |
      |     4 | Divin  |      0 |   5000 |   32 |
      |     5 | Edwin  |      1 |   2500 |   55 |
      |     7 | George |      0 |   1500 |   46 |
      +-------+--------+--------+--------+------+
      6 rows in set (0.00 sec)
  
  mysql&gt; select * from works;
  +----------+-------+---------+
  | courseid | empid | classid |
  +----------+-------+---------+
  |        1 |     1 |      10 |
  |        2 |     2 |       9 |
  |        3 |     3 |       8 |
  |        4 |     4 |      10 |
  |        5 |     5 |       9 |
  |        6 |     1 |       9 |
  |        2 |     3 |      10 |
  |        2 |     1 |       7 |
  |        4 |     2 |       6 |
  |        2 |     4 |       6 |
  |        2 |     5 |       2 |
  |        7 |     5 |       6 |
  |        3 |     5 |       2 |
  |        6 |     4 |      10 |
  +----------+-------+---------+
  14 rows in set (0.00 sec)
  
  mysql&gt; select * from course;
  +----------+------------+--------+
  | courseid | coursename | points |
  +----------+------------+--------+
  |        1 | Maths      |      5 |
  |        2 | Science    |      1 |
  |        3 | English    |      6 |
  |        4 | Social     |      4 |
  |        5 | Malayalam  |     20 |
  |        6 | Arts       |     25 |
  |        7 | Biology    |     20 |
  +----------+------------+--------+
  7 rows in set (0.00 sec)
  </code></pre>
  
  <p>Question is :</p>
  
  <blockquote>
    <p>List those professors who have not taught any course in the three
    classes Class 7,8,9</p>
  </blockquote>
  
  <p>My query is :</p>
  
  <pre><code>select professor.name from professor
  inner join works
  on professor.empid=works.empid
  group by works.empid
  having works.classid not in (7,8,9);
  </code></pre>
  
  <p>The ouput I get is :</p>
  
  <pre><code>Arun    
  Divin   
  </code></pre>
  
  <p>The ouput I am actually required to get :</p>
  
  <p>Divin</p>
  
  <p>Pls help me out.</p>
  
  <p><a href="http://sqlfiddle.com/#!2/77ec7/46" rel="nofollow">http://sqlfiddle.com/#!2/77ec7/46</a></p>