Index: taxonomy.php
===================================================================
--- taxonomy.php	(revision 16536)
+++ taxonomy.php	(working copy)
@@ -526,7 +526,14 @@
 	$join = '';
 	$where = '';
 	$i = 0;
+	if ( !empty( $tax_query['relation'] ) ) {
+		$relation = $tax_query['relation'];
+	} else {
+		$relation = 'AND';
+	}
 	foreach ( $tax_query as $query ) {
+		if ( !is_array( $query ) ) continue;
+		
 		extract( wp_parse_args( $query, array(
 			'taxonomy' => array(),
 			'terms' => array(),
@@ -576,9 +583,11 @@
 			$join .= " INNER JOIN $wpdb->term_relationships";
 			$join .= $i ? " AS $alias" : '';
 			$join .= " ON ($primary_table.$primary_id_column = $alias.object_id)";
+			
+			if ($i) $where .= " $relation"; 
+			
+			$where .= " $alias.term_taxonomy_id $operator ($terms)";
 
-			$where .= " AND $alias.term_taxonomy_id $operator ($terms)";
-
 			$i++;
 		}
 		elseif ( 'NOT IN' == $operator ) {
@@ -587,14 +596,20 @@
 
 			$terms = implode( ',', $terms );
 
-			$where .= " AND $primary_table.$primary_id_column NOT IN (
+			if ($i) $where .= " $relation"; 
+			
+			$where .= " $primary_table.$primary_id_column NOT IN (
 				SELECT object_id 
 				FROM $wpdb->term_relationships 
 				WHERE term_taxonomy_id IN ($terms)
 			)";
+			
+			$i++;
 		}
 	}
-
+	
+	$where = ' AND ( ' . $where . ' )';
+	
 	return compact( 'join', 'where' );
 }
 
