Return rows from the first query not present in the second.
Section: EXISTS and Set Operations
Subtract rows with EXCEPT
sql
sql
SELECT user_id FROM all_users
EXCEPT
SELECT user_id FROM banned_users;Explanation
Some dialects use MINUS instead of EXCEPT.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing EXISTS and Set Operations