diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index 03749a329b..535c7b7824 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -368,6 +368,9 @@ public function addRelationship($alias, JoinPluginBase $join, $base, $link_point
       return FALSE;
     }
 
+    // Ensure the table alias is no longer than 60 characters long.
+    $alias = (strlen($alias) > 60) ? substr($alias, -60) : $alias;
+
     // Make sure $alias isn't already used; if it, start adding stuff.
     $alias_base = $alias;
     $count = 1;
@@ -548,6 +551,17 @@ protected function markTable($table, $relationship, $alias) {
         }
         $alias .= $table;
       }
+      
+      // Ensure the table alias is no longer than 60 characters long.
+      $alias = (strlen($alias) > 60) ? substr($alias, -60) : $alias;
+
+      // Make sure $alias isn't already used; if it, start adding stuff.
+      $alias_base = $alias;
+      $count = 1;
+      while (!empty($this->relationships[$alias])) {
+        $alias = $alias_base . '_' . $count++;
+      }
+      
       $this->tables[$relationship][$table] = [
         'count' => 1,
         'alias' => $alias,
