- UNION is used to select distinct values from two tables.
- Union are slow as compare to Union ALL
- UNION similar to JOIN command.
- When using the UNION command all selected columns need to be of the same data type.
Example
SELECT
'TEST'
UNION
SELECT 'TEST'RESULT:
TEST
UNION ALL
- UNION ALL will not eliminate duplicate rows; instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.
- UNION ALL is faster
SELECT
'TEST'
UNION ALL
SELECT
'TEST'TEST
TEST
Comments
Post a Comment