login

SQL MINUS or EXCEPT Operator

SQL MINUS or EXCEPT operator work on two table expressions. The result set takes records from the first table expression, and then subtract out the ones that appear in the second table expression. If the second table expression includes the records which are not appear in the first table expression, these records will be ignored.

The syntax of using SQL MINUS is simple as follows :

table_expression1
MINUS
table_expression2
table_expression1
EXCEPT
table_expression2

Be noted that the MINUS operator only returns distinct values from table expression.

SQL MINUS or EXCEPT operator is one of the set operators. SQL MINUS or EXCEPT is equivalent of the difference operator from set theory. Some RDBMS uses MINUS and the other uses EXCEPT keyword.