Select data from database For the filter block I need to get the data from database. I have three tables "node", "node__filed_country" and "taxonomy_index". So I need to pull only those taxonomies which are realted to the nodes, which field_country is equal to three particular countries. So I need to provide two joins. 

$query = $this-&gt;connection-&gt;select('node', 'node');
$query-&gt;join('node__field_country', $nfc, "node.nid=$nfc.entity_id and ($nfc.field_country_target_id=1 or $nfc.field_country_target_id=2 or $nfc.field_country_target_id=3)");
$query-&gt;join('taxonomy_index', $id, "$id.nid = node.nid AND $id.tid = $term-&gt;tid AND $id.status = 1 ");
$query-&gt;execute()-&gt;fetchField();


But something doesnt work in this code. Could you please help me?
You try code

$term_id = 1;
  $query = $this-&gt;connection-&gt;select('node', 'node');
  $query-&gt;join('node__field_country', "nfc", "node.nid=nfc.entity_id and (nfc.field_country_target_id=1 or nfc.field_country_target_id=2 or nfc.field_country_target_id=3)");
  $query-&gt;join('taxonomy_index', "tid", "tid.nid = node.nid AND tid.tid =".$term_id." AND tid.status = 1 ");
  $query-&gt;execute()-&gt;fetchField();