title: Convert SQL to Doctrine 2 Query Builder or DQL by using NOT IN?
body: <p>How would I convert the SQL bellow to Doctrine 2 Query Builder or DQL?</p>
  
  <pre><code>SELECT tags.* 
  FROM tags 
  WHERE tags.id NOT IN (
                       SELECT tag_id AS totalTags 
                       FROM human_resource_tags 
                       WHERE human_resource_id=1)
  </code></pre>
  
  <p>Tag entity is as follows:</p>
  
  <p><a href="http://pastebin.com/nL499ee1" rel="nofollow">Tag entity</a></p>
  
  <p>HumanResource entity is as follows:</p>
  
  <p><a href="http://pastebin.com/gPccQ6pi" rel="nofollow">HumanResource entity</a></p>
  
  <p>Basically what I want to do is to select all Tag entities for one HumanResource entity that that HumanResource entity does not have already.</p>
  
  <p>I am really struggling here so any help is appreciated.</p>
  
  <p>I am using Doctrine version 2.4.2.</p>
  
  <p>==========================================================================</p>
  
  <p>All hail to FuzzyTree for pointers :)</p>
  
  <p>I have slightly modified it and it works like a charm :)
  So this will get you all Tag entities for particular HumanResource entity that are not added to 
  HumanResource entity yet :)</p>
  
  <p>SO THIS IS SOLUTION:</p>
  
  <pre><code>$q = $this-&gt;createQueryBuilder('t')
        -&gt;where('t.name LIKE :name')
        -&gt;andWhere('NOT EXISTS (
                      SELECT h
                      FROM HRAPIBundle:HumanResource h 
                      WHERE h.id = ' . $humanResource-&gt;getId() .
                      'AND h MEMBER of t.human_resources
                  )')
        -&gt;setParameter('name', "%".$query."%")
        -&gt;getQuery();
  </code></pre>