11 - UNION , UNION ALL

 

UNION 

The UNION command combines the result set of two or more SELECT statements (only distinct values).


UNION ALL

The Union All extracts all the rows including the duplicates (repeated values) from both the queries.


ORIGINAL GENERATED LIST

 

   market_1                                                                             market_2

                                  



Make a final table from market_1 and market_2 which covers all products and

 duplicate product becomes distinct

select product from market_1
UNION
select product from market_2;




Make a final table from market_1 and market_2 which covers all products and

 duplicate product stays duplicate

select product from market_1
UNION ALL
select product from market_2;



Comments

Popular posts from this blog

5 - DML commands used in MySQL WorkBench

INDEX OF Zeek MySQL

4 - DDL commands used in MySQL Workbench