diff --git a/views/relation_handler_relationship.inc b/views/relation_handler_relationship.inc
index b708af5..92510e6 100644
--- a/views/relation_handler_relationship.inc
+++ b/views/relation_handler_relationship.inc
@@ -81,7 +81,7 @@ class relation_handler_relationship extends views_handler_relationship {
         ),
       ),
     );
-    if (isset($this->definition['entity_type_left'])) {
+    if (isset($this->definition['entity_type_left']) && !($this->view->base_table == 'relation') && !($this->definition['relationship field'] == 'rid')) {
       // The other table is an entity we are relating to.
       $join->definition['field'] = $entity_id_field_name;
       $this->ensure_no_duplicate_entities($join->definition['extra'], $this->options['entity_deduplication_left'], $this->definition['relation_type'], $this->definition['entity_type_left'], $this->table_alias, $this->real_field);
@@ -90,6 +90,9 @@ class relation_handler_relationship extends views_handler_relationship {
         'value' => $this->definition['entity_type_left'],
       );
     }
+    elseif($this->definition['base'] == 'relation') {
+      $join->definition['field'] = 'endpoints_entity_id';
+    }
     else {
       // The other table is relation.
       $join->definition['field'] = 'entity_id';
@@ -146,7 +149,7 @@ class relation_handler_relationship extends views_handler_relationship {
         'value' => 1,
       );
     }
-    if (isset($this->definition['entity_type_right'])) {
+    if (isset($this->definition['entity_type_right']) && !($this->definition['base'] == 'relation')) {
       // We are finishing on an entity table.
       $join->definition['left_field'] = $entity_id_field_name;
       $this->ensure_no_duplicate_entities($join->definition['extra'], $this->options['entity_deduplication_right'], $this->definition['relation_type'], $this->definition['entity_type_right'], $r, $entity_id_field_name);
@@ -156,6 +159,9 @@ class relation_handler_relationship extends views_handler_relationship {
         'value' => $this->definition['entity_type_right'],
       );
     }
+    elseif (isset($this->definition['entity_type_left']) && !($this->definition['base'] == 'relation')) {
+     $join->definition['left_field'] = $entity_id_field_name;
+    }
     else {
       // We are finishing on relation.
       $join->definition['left_field'] = 'entity_id';
