Index: src/wp-includes/taxonomy.php
===================================================================
--- src/wp-includes/taxonomy.php	(revision 25254)
+++ src/wp-includes/taxonomy.php	(working copy)
@@ -1310,9 +1310,10 @@
 		$inclusions = implode( ',', wp_parse_id_list( $include ) );
 	}
 
-	if ( ! empty( $inclusions ) )
+	if ( ! empty( $inclusions ) ) {
 		$inclusions = ' AND t.term_id IN ( ' . $inclusions . ' )';
-	$where .= $inclusions;
+		$where .= $inclusions;
+	}
 
 	$exclusions = '';
 	if ( ! empty( $exclude_tree ) ) {
@@ -1339,8 +1340,10 @@
 		$exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')';
 
 	$exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args );
-	$where .= $exclusions;
 
+	if ( ! empty( $exclusions ) )
+		$where .= $exclusions;
+
 	if ( !empty($slug) ) {
 		$slug = sanitize_title($slug);
 		$where .= " AND t.slug = '$slug'";
Index: tests/phpunit/tests/term/getTerms.php
===================================================================
--- tests/phpunit/tests/term/getTerms.php	(revision 25254)
+++ tests/phpunit/tests/term/getTerms.php	(working copy)
@@ -121,10 +121,11 @@
 	}
 
  	/**
-	 * @ti
-	 * cket 11823
+	 * @ticket 11823
  	 */
 	function test_get_terms_include_exclude() {
+		global $wpdb;
+
 		$term_id1 = $this->factory->tag->create();
 		$term_id2 = $this->factory->tag->create();
 		$inc_terms = get_terms( 'post_tag', array(
@@ -138,6 +139,16 @@
 			'hide_empty' => false
 		) );
 		$this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) );
+
+		// These should not generate query errors.
+		get_terms( 'post_tag', array( 'exclude' => array( 0 ), 'hide_empty' => false ) );
+		$this->assertEmpty( $wpdb->last_error );
+
+		get_terms( 'post_tag', array( 'exclude' => array( 'unexpected-string' ), 'hide_empty' => false ) );
+		$this->assertEmpty( $wpdb->last_error );
+
+		get_terms( 'post_tag', array( 'include' => array( 'unexpected-string' ), 'hide_empty' => false ) );
+		$this->assertEmpty( $wpdb->last_error );
 	}
 
 	/**
