Index: includes/database/select.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/select.inc,v
retrieving revision 1.28
diff -u -p -r1.28 select.inc
--- includes/database/select.inc	10 Nov 2009 22:15:24 -0000	1.28
+++ includes/database/select.inc	14 Nov 2009 17:28:55 -0000
@@ -1123,6 +1123,7 @@ class SelectQuery extends Query implemen
   }
 
   public function fields($table_alias, array $fields = array()) {
+    static $weight = 0;
 
     if ($fields) {
       foreach ($fields as $field) {
@@ -1133,6 +1134,8 @@ class SelectQuery extends Query implemen
     else {
       // We want all fields from this table.
       $this->tables[$table_alias]['all_fields'] = TRUE;
+      // Additionally make sure tables appear in the order they were specified.
+      $this->tables[$table_alias]['weight'] = $weight++;
     }
 
     return $this;
@@ -1285,6 +1288,8 @@ class SelectQuery extends Query implemen
 
     // FIELDS and EXPRESSIONS
     $fields = array();
+    // Sort tables in the order they were specified.
+    uasort($this->tables, 'drupal_sort_weight');
     foreach ($this->tables as $alias => $table) {
       if (!empty($table['all_fields'])) {
         $fields[] = $alias . '.*';
