diff --git a/handlers.inc b/handlers.inc
index cc7d6b8..db3f278 100644
--- a/handlers.inc
+++ b/handlers.inc
@@ -416,7 +416,7 @@ class views_handler extends views_object {
    */
   function ensure_my_table() {
     if (!isset($this->table_alias)) {
-      $this->table_alias = $this->query->ensure_table($this->table, $this->relationship);
+      $this->table_alias = str_replace('-', '_', $this->query->ensure_table($this->table, $this->relationship));
     }
     return $this->table_alias;
   }
@@ -1238,6 +1238,7 @@ class views_join {
    * Build the SQL for the join this object represents.
    */
   function join($table, &$query) {
+    $table[alias] = str_replace('-', '_', $table[alias]);
     if (empty($this->definition['table formula'])) {
       $right_table = "{" . $this->table . "}";
     }
