Are you familiar with the UNION statement for your SQL queries? Most likely, you are. It has been supported for a long time.
In case you are not familiar with UNION, don’t worry, I’m going to show you how it works with simple examples.
Considering “Set Theory”, other than the UNION, starting from the newly deployed MySQL Community 8.0.31, a couple of new clauses are available: INTERSECT and EXCEPT.
From now on you can rely on more powerful options to write your queries and deploy some Set Theory logic.
In this article, I’m going to present how the three options work.
The traditional UNION
UNION combines the results from two or multiple SELECT statements into a single result set. Let’s suppose you have two queries, A and B, they return the same number of columns with the same data types and you need to merge all rows from both queries into a single result set. You can …
[Read more]