title: query within the sub-query in doctrine2 query builder not working
body: <p>I have a following table structure</p>
  
  <p>TABLE : doctors</p>
  
  <pre><code>id name 
  1  Mac
  2  Smit
  </code></pre>
  
  <p>TABLE : Organizations</p>
  
  <pre><code>id name
  1  Org1
  2 Org2
  </code></pre>
  
  <p>TABLE : org_doctors</p>
  
  <pre><code>id org_id doctor_id
  1   1      1
  2   1      2
  </code></pre>
  
  <p>TABLE : specializations</p>
  
  <pre><code>id name
  1 ENT
  2 Cardiac
  </code></pre>
  
  <p>TABLE : doc_specialzations</p>
  
  <pre><code>id doctor_id specialzation_id
  1  1          1
  2  1          2
  3  2          1
  </code></pre>
  
  <p>Below is the doctrine code i am working in:</p>
  
  <pre><code>$qb = $this-&gt;entityManager-&gt;createQueryBuilder();
      $qb2 = $qb;
      $qb2-&gt;select('dsp.doctor_id')
              -&gt;from('Doctor\Entity\DoctorSpecialization', 'dsp')
              -&gt;where('dsp.specialization = :specializationId')
              -&gt;setParameter('specializationId', $searchBy['specialization']);
  
  
      $qb-&gt;select('od', 'd', 'o', 'u')
              -&gt;from('Doctor\Entity\OrgDoctor', 'od')
              -&gt;leftJoin('od.organization', 'o')
              -&gt;leftJoin('od.doctor', 'd')
              -&gt;leftJoin('d.user', 'u');
  
  
      $qb-&gt;where($qb-&gt;expr()-&gt;in('od.doctor', $qb2-&gt;getDQL()));
  
  $qb-&gt;andWhere('od.organization IN (:organizations)')
                  -&gt;andWhere('d.active = true')
                  -&gt;andWhere('od.active = true')
                  -&gt;setParameter('organizations', $organizations);
  </code></pre>
  
  <p>When working on the abvoe code, i am getting the following error:</p>
  
  <pre><code>[Syntax Error] line 0, col 188: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_FROM, got ','
  </code></pre>
  
  <p>This is my DoctorSpecialization Entity:</p>
  
  <pre><code>/**
   * @ORM\Entity
   * @ORM\Table(name="doctors_specializations")
   */
  
  class DoctorSpecialization extends BaseEntity{
  
      /**
       * @ORM\ManyToOne(targetEntity="Doctor\Entity\Doctor", inversedBy="docSpecialization")
       * @ORM\JoinColumn(name="doctor_id",referencedColumnName="id",nullable=false)
       */
      protected $doctor;
  
      /**
       * @ORM\ManyToOne(targetEntity="Doctor\Entity\Specialization", inversedBy="docSpecialization")
       * @ORM\JoinColumn(name="specialization_id", referencedColumnName="id", nullable=false)
       */
      protected $specialization;
  
      public function setDoctor(Doctor $doctor = null)
      {
          $this-&gt;doctor = $doctor;
  
          return $this;
      }
  
      public function getDoctor()
      {
          return $this-&gt;doctor;
      } 
  
      public function setSpecialization(Specialization $specialization = null)
      {
          $this-&gt;specialization = $specialization;
  
          return $this;
      }
  
      public function getSpecialization()
      {
          return $this-&gt;specialization;
      }  
  
  }
  </code></pre>