title: How to fix "Error: Expected Literal, got 'SELECT'" with queryBuilder?
body: <p>I have a problem with a query i did, when i try to make a subquery i have this error message </p>
  
  <pre><code>"hydra:description": "[Syntax Error] line 0, col 85: Error: Expected Literal, got 'SELECT'",
  </code></pre>
  
  <p>for this query in my EventRepositoty CLass:</p>
  
  <pre><code>public function updateMoveAtField(string $eventLabel, $cameraId)
  {
      $queryBuilder = $this-&gt;createQueryBuilder('e');
      $subQueryBuilder = $this-&gt;createQueryBuilder('ev');
  
      $subQuery = $subQueryBuilder
          -&gt;select('MAX(ev.arrivedAt) as arrived')
          -&gt;andWhere('ev.camera = ?1')
          -&gt;setParameter(1, $cameraId)
          -&gt;getQuery()-&gt;getDQL()
      ;
  
      $event = $queryBuilder
          -&gt;update()
          -&gt;set('e.moveAt', '?1')
          -&gt;where('e.label = ?2')
          -&gt;andWhere('e.camera = ?3')
          -&gt;andWhere($queryBuilder-&gt;expr()-&gt;andX($subQuery))
          -&gt;setParameter(1, new \DateTime())
          -&gt;setParameter(2, $eventLabel)
          -&gt;setParameter(3, $cameraId);
  
      return $event-&gt;getQuery()-&gt;execute();
  }
  </code></pre>
  
  <p>how can i fix it? </p>
  
  <p>I dont know if you can understand my request so let me explain : i want to update a fiel "moveAt" when the label &amp; camera its the same ones that were sent in the query. so i did a subquery because i want and other condition who are (always update the last one). i do a subquery because i can't add a select in a Update query. </p>
  
  <p>EDIT :
  Result of DQL dump from @Preciel help</p>
  
  <blockquote>
    <p>"SELECT MAX(e.arrivedAt) FROM App\Entity\Event e WHERE e.label=:var2
    AND e.camera=:var3 AND e.camera=:var3 AND (e.arrivedAt &lt;= SELECT
    MAX(e.arrivedAt) FROM App\Entity\Event e WHERE e.label=:var2 AND
    e.camera=:var3 AND e.camera=:var3)"</p>
  </blockquote>
  
  <p>new =</p>
  
  <blockquote>
    <p>"UPDATE App\Entity\Event e SET event.moveAt = :var1 WHERE
    e.label=:var2 AND e.camera=:var3 AND e.arrivedAt &lt;= SELECT
    MAX(ev.arrivedAt) FROM App\Entity\Event ev WHERE ev.camera=:var3"</p>
  </blockquote>
  
  <p>subquery</p>
  
  <blockquote>
    <p>"SELECT MAX(ev.arrivedAt) FROM App\Entity\Event ev WHERE
    ev.camera=:var3"</p>
  </blockquote>