Another use for this technique is to test a rewritten query to confirm its results match those of the original. One reason to rewrite a query is better performance as “interesting syntax” may prevent the optimizer from calculating a better plan. For complicated queries, it may be best to first write results to a temp tables, eg before and after, then apply the EXCEPT operator to them. As you can infer, I use this technique often 🙂
Thank you for this informative video. I was an Oracle programmer for a long time and often used UNION but never looked into using EXCEPT. Very nice.
This was really useful, thanks! A few notes: 1) I see you are using DataGrip in this video. I've switched to DataGrip from Navicat although there a few things I think Navicat does better. 2) I just verified that EXCEPT also works in SQLite. 3) However, SQLite does not seem to like it if I just wrap a statement in parentheses. If I add a SELECT clause before the first opening parenthese, it works. I'm going to try to use this in my current project.
SQL Server supports the EXCEPT operator
@DatabaseStar