Skip to Content
Learn
Set Operations
Except

EXCEPT is constructed in the same way, but returns distinct rows from the first SELECT statement that aren’t output by the second SELECT statement.

SELECT column_name(s) FROM table1 EXCEPT SELECT column_name(s) FROM table2;

Suppose we want to see if there are any categories that are in the new_products table that aren’t in the legacy_products table. We can use an EXCEPT query to perform this analysis:

SELECT category FROM new_products EXCEPT SELECT category FROM legacy_products;

Instructions

1.

Conversely, select the items in the category column that are in the legacy_products table and not in the new_products table.

Folder Icon

Sign up to start coding

Already have an account?