entityQuery array instead of orConditionGroup() I'd written a query based on the "simplified" version here. And my code looked like this.

$results = \Drupal::entityQuery('node')
  -&gt;condition('type', 'mytype')
  -&gt;condition('status', 1)
  -&gt;condition('field_first.target_id', $anArrayOfNids)
  -&gt;condition('field_seciond.target_id', array($anotherNid))
  -&gt;execute();


The code was working, I know it was. But now I'm getting an "SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens" SQL error.

I tried replacing it with just array(540) and got the proper result. Then I gave it array(546) and got the different, expected response, but as soon as I put [540,560] or array(540,560), I get that error, instead of what i used to get, which was the combined results.
I don't know how it was working before, but the solution seems to be to place the explicit 'IN' in the query as such:

$results = \Drupal::entityQuery('node')
  -&gt;condition('type', 'mytype')
  -&gt;condition('status', 1)
  -&gt;condition('field_first.target_id', $anArrayOfNids, 'IN')
  -&gt;condition('field_seciond.target_id', array($anotherNid))
  -&gt;execute();


Or, if I was to just convert this to the more complicated, yet more robust method:

$results = \Drupal::entityQuery('node');
$group = $query-&gt;orConditionGroup();
foreach($anArrayOfNids as $nid) {
  $group-&gt;condition(field_first.target_id, array($nid));
}
$query-&gt;condition('type', 'mytype')
  -&gt;condition('status', 1)
  -&gt;condition('field_seciond.target_id', array($anotherNid))
  -&gt;condition($group)
  -&gt;execute();