Question №16
Remaining:
Explain the difference between UNION and UNION ALL
Sample Answer
Show Answer by Default
UNION:
- Combines the results of two or more SELECT queries.
- Removes duplicates from the combined result.
Syntax
MySQL 8.1SELECT column_list FROM table1 UNION SELECT column_list FROM table2;
UNION ALL:
- Combines the results of two or more SELECT queries.
- Retains duplicates in the combined result.
- Performs faster as it doesn’t perform the additional operation of removing duplicates.
Syntax
MySQL 8.1SELECT column_list FROM table1 UNION ALL SELECT column_list FROM table2;