Index: Select.php =================================================================== --- Select.php (Revision 17003) +++ Select.php (working copy) @@ -1085,9 +1085,14 @@ if ($target instanceof Zend_Db_Select) { $target = $target->assemble(); } + if ($cnt == 0) { + $sql .= '('; + } $sql .= $target; if ($cnt < $parts - 1) { - $sql .= ' ' . $type . ' '; + $sql .= ') ' . $type . ' ('; + } else { + $sql .= ')'; } } }