How can I insert a variable into query condition?
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);