PostgreSQL – EXCEPT operator

Postgres EXCEPT operator is used to compare the result sets of 2 queries . It returns rows from first query that are not in the second query; similar to MINUS operator in Oracle.

Syntax:

SELECT col11,col12,col13 from table1
EXCEPT
SELECT col21,col22,col23 from table2;

Both the select statements should have the same number of columns and same data types.

See also  PostgreSQL - Remove all special characters from a string