How can I insert a variable into query condition? I am writing a query, and the question is how can I insert an array variable into condition statement. So instead of having (1060,968,1106) I would like to place there an array. 

$fields; // array with some predefined ids 
$query = $this-&gt;connection-&gt;select('node', 'node');
$query-&gt;innerJoin('node__field_field', 'nfc', "nfc.entity_id=node.nid AND
                (nfc.field_field_target_id IN (1060,968,1106))");


I tried 

$query-&gt;innerJoin('node__field_field', 'nfc', "nfc.entity_id=node.nid AND
                (nfc.field_field_target_id IN ".$fields." )");


But it doesn't work, could you please help me?
Outside of extreme circumstances, never, ever concatenate variables into an SQL string. You'll leave yourself open to SQL injection.

It feels like you should be using an entity query for this, but for the sake of the exercise, use a placeholder and pass the arguments in:

$args = [
  ':fields[]' =&gt; ['id_1', 'id_2', 'id_3'],
];
$query-&gt;innerJoin('node__field_field', 'nfc', 'nfc.entity_id=node.nid AND nfc.field_field_target_id IN (:fields[])', $args);