Technology and Trends

What are SQL Unions?

SQL Stands for Structured Query Language(SQL). SQL UNION combines the results of two or more queries into a single result set in a database that includes all the rows that belong to all queries in the union.

SELECT 1 AS [Column1], 2 AS [Column2] UNION SELECT 3 AS [Column1], 4 AS [Column2] 
SQL Union

Figure: Union

Union vs Union All

Union combines two tables by removing duplicates, whereas Union All combines two tables by including all data, even if they are duplicates.

Differences Between UNION, MINUS, and INTERSECT

Exit mobile version