PostgreSQL UNION, INTERCEPT & EXCEPT Operator


Overview

In this tutorial, you will learn how to use the PostgreSQL Union, Intercept and Except operators to combine result sets of two or more queries. These operators helps to combine result sets of two select statements into a single result .

UNION Operator

The UNION operator helps to combine the result sets of two or more select statements into a single result set.

Basic Syntax

SELECT col1,col2..colN FROM table A UNION SELECT col1,col2..colN FROM table B;

As Union means in English, this query returns combined result set from both the tables. However, no duplicates are returned. To retain the