title: Doctrine 2 subquery
body: <p>I want to implement a subquery using the query builder but I'm not understanding the syntax. I'm dealing with a locations table that has entries that can be cities, states or zip codes depending on the location type set. I want to get all locations that are in a certain state and take out any that are city type and have a population below a certain amount.</p>
  
  <pre><code>$qb-&gt;select('l')
  -&gt;from('Entity\Location', 'l')
  -&gt;where('l.state = :state')
  -&gt;setParameter('state', 'UT')
  -&gt;andWhere('...don't know what to put here');
  </code></pre>
  
  <p>In the andWhere I basically need to say </p>
  
  <blockquote>
    <p>and where id not in (select id from location where location_type = 1 and population &lt; 1000)</p>
  </blockquote>
  
  <p><strong>Update</strong>: I was able to do this with straight DQL but it would be nice to see how to do it using the query builder.</p>
  
  <pre><code>$qb-&gt;andWhere('l.id NOT IN (SELECT l2.id FROM Entity\Location AS l2 WHERE l2.location_type = 1 AND l2.population &lt; 1000)');
  </code></pre>