MySQL supports a few Set operations which can be performed on the data in the table. These are used to create meaningful relationships between different tables or query results to combine and analyse data.
There are 3 different types of SET operations:
- UNION ALL
The UNION set operation is used to combine the outputs of two or more SELECT statements. This will eliminate duplicates from its result set. The number of columns and the datatype must be the same in both the tables on which the UNION operation is being used.
SELECT FROM FirstUNIONSELECT FROM Second;
This operation is similar to Union with the only difference being that it also shows the duplicate rows.
SELECT * FROM FirstUNION ALLSELECT * FROM Second;
The Minus set operation combines the results of two SELECT statements and returns only those in the final result, which belongs to the first set of the result.
SELECT * FROM FirstMINUSSELECT * FROM Second;
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs