Cloud

Set Operations

Set operations combine, compare, or contrast result sets from multiple SELECT statements. Redpanda SQL supports the following operations:

  • Union: Combines two or more sets to create a new set containing all unique elements from the input sets.

  • Intersect: Yields a new set with elements common to all input sets.

  • Except: Generates a set containing elements from the first set that are not present in the second set.

For all set operations, the data types of corresponding columns in the SELECT queries must be compatible. The order of columns is flexible as long as the columns in consecutive places are pairwise compatible. For example, SELECT col1, col2 FROM table1 UNION SELECT col2, col1 FROM table2.