title: MYSQL clause IN
body: <p><a href="https://api.genmymodel.com/projects/_Fiqh0AYoEeaCaNzs6cfLZA/diagrams/_Fiqh0gYoEeaCaNzs6cfLZA/jpeg" rel="nofollow">https://api.genmymodel.com/projects/_Fiqh0AYoEeaCaNzs6cfLZA/diagrams/_Fiqh0gYoEeaCaNzs6cfLZA/jpeg</a></p>
  
  <p>I have one or more keywords and I want to find all doctor who are associate to all of them.
  How to do that in Mysql.</p>
  
  <p>I try :  </p>
  
  <pre><code>SELECT *
  FROM Doctor, DoctorKeyword, Keyword 
  WHERE DoctorKeyword.idKeyword IN (SELECT id 
                                    FROM Keyword 
                                    WHERE word = "test" 
                                    OR word = "anotherTest") 
  AND DoctorKeyword.idDoctor = Doctor.id 
  HAVING COUNT(DISTINCT DoctorKeyword.idKeyword)= 2
  </code></pre>
  
  <p>I want to find all doctors who have all keywords in the IN clause</p>
  
  <pre><code>Exemple of table Doctor
  
      id|name    |address
      1 | John   | los Angeles
      2 | Patrick| Miami
      3 | Michal | Miami
  
  Exemple of table Keyword
  
      id|word
      1 | test
      2 | anotherTest
      3 | merc
  
  Exemple of table DoctorKeyword
  
      id|idDoctor|idKeyword
      1 | 1      | 1
      2 | 1      | 2
      3 | 2      | 3
      4 | 2      | 1
      5 | 2      | 2
  </code></pre>