title: Filtering joined data
body: <p>I have a model with several entities.
  Most important are Transportevent and Transporteventtype that are connected by association Transportstatus.
  Therefore, Transportstatus contains foreign keys to those two tables.</p>
  
  <p>In my query, I am trying to filter Transportstatustype id values. My query is inside a Transportevent repository, and $this->getAlias() returns "transportevent".</p>
  
  <pre><code>public function findAllDispatchedEvents($limit)
      {
  
          $transportstatusAlias = "ts";
          $transporteventtypeAlias = "tet";
          $transportstatustypeAlias = "tst";
          $crewAlias = "c";
  
          $qb = $this-&gt;createQueryBuilder($this-&gt;getAlias());
  
          $qb-&gt;leftJoin($this-&gt;getAlias() . '.crew', $crewAlias)
              -&gt;leftJoin($this-&gt;getAlias() . '.transporteventtype', $transporteventtypeAlias)
              -&gt;leftJoin($this-&gt;getAlias() . '.transportstatuses', $transportstatusAlias)
              -&gt;leftJoin($transportstatusAlias . '.transportstatustype', $transportstatustypeAlias)
              -&gt;where($this-&gt;getAlias() . ".transporteventtype &lt;&gt; 3")
              -&gt;andWhere($crewAlias . ".crewid IS NOT NULL")
              -&gt;andWhere($transportstatustypeAlias . ".tstypeid NOT IN (10, 15, 17)")
              -&gt;orderBy($this-&gt;getAlias() . ".actualstart", "DESC")
              -&gt;setMaxResults($limit);
  
          return $qb-&gt;getQuery()-&gt;getResult();
      }
  </code></pre>
  
  <p>However, I'm not getting what I need. It seems that it's not possible to perform where clause over another table in a join.</p>
  
  <p>Or am I doing something wrong?</p>
  
  <p>As you can see, I need these results by certain conditions, where tstypeid is not in array (10, 15, 17). But I'm getting those values as well anyway.
  Any suggestions?</p>