diff --git a/modules/taxonomy/views_handler_relationship_node_term_data.inc b/modules/taxonomy/views_handler_relationship_node_term_data.inc
index 2f013da..997352a 100644
--- a/modules/taxonomy/views_handler_relationship_node_term_data.inc
+++ b/modules/taxonomy/views_handler_relationship_node_term_data.inc
@@ -48,27 +48,29 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh
   function query() {
     $this->ensure_my_table();
 
-    $def = $this->definition;
+    $vocabularies = array_filter($this->options['vocabularies']);
+
+    $def = array();
     $def['table'] = 'taxonomy_term_data';
 
-    if (!array_filter($this->options['vocabularies'])) {
+    if (empty($vocabularies) || !empty($this->options['required'])) {
       $term_node = $this->query->add_table('taxonomy_index', $this->relationship);
-      $def['left_table'] = 'taxonomy_index';
+      $def['left_table'] = $term_node;
       $def['left_field'] = 'tid';
       $def['field'] = 'tid';
       $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
     }
     else {
-      // If vocabularies are supplied join a subselect instead
+      // If vocabularies are supplied and the relationship is not required, join a subselect.
       $def['left_table'] = $this->table_alias;
       $def['left_field'] = 'nid';
       $def['field'] = 'nid';
-      $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
+      $def['type'] = 'LEFT';
 
       $query = db_select('taxonomy_term_data', 'td');
-      $query->addJoin($def['type'], 'taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
-      $query->addJoin($def['type'], 'taxonomy_index', 'tn', 'tn.tid = td.tid');
-      $query->condition('tv.machine_name', array_filter($this->options['vocabularies']));
+      $query->addJoin('INNER', 'taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+      $query->addJoin('INNER', 'taxonomy_index', 'tn', 'tn.tid = td.tid');
+      $query->condition('tv.machine_name', $vocabularies);
       $query->addTag('term_access');
       $query->fields('td');
       $query->fields('tn', array('nid'));
@@ -76,14 +78,30 @@ class views_handler_relationship_node_term_data extends views_handler_relationsh
     }
 
     $join = new views_join();
-
     $join->definition = $def;
     $join->construct();
-    $join->adjusted = TRUE;
 
-    // use a short alias for this:
     $alias = $def['table'] . '_' . $this->table;
-
     $this->alias = $this->query->add_relationship($alias, $join, 'taxonomy_term_data', $this->relationship);
+
+    if (!empty($vocabularies) && !empty($this->options['required'])) {
+      // If vocabularies are supplied and the relationship is required, inner join the vocabulary.
+      $def = array();
+      $def['table'] = 'taxonomy_vocabulary';
+      $def['left_table'] = 'taxonomy_term_data';
+      $def['left_field'] = 'vid';
+      $def['field'] = 'vid';
+      $def['type'] = 'INNER';
+      $def['extra'] = array(array(
+        'field' => 'machine_name',
+        'value' => $vocabularies,
+      ));
+
+      $join = new views_join();
+      $join->definition = $def;
+      $join->construct();
+
+      $vocabulary = $this->query->ensure_table('taxonomy_vocabulary', $this->alias, $join);
+    }
   }
 }
