Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.3 kB
9
Indexable
Never
16/02/2024
===============================================================================================
Union and Union all
-------------------------
union operators:
union operator is use to find the resultset or combination of two or more tables.

union operator select only distinct or unique values(records) 

rules:
1.Each table must within union must have same number of column.
2.the column must be the same data types.
3.the column in each sequence must be same.

syntax:
select columns from table1
union
select columns from table2;

select * from order2;
select * from order1;

select * from order1
union
select * from order2;

select ord_id ,item from order1
union
select ord_id,item from order2;

----------------------------------------------------------------------------------------------------------------

union all operators:
union all operator is use to find the resultset or combination of two or more tables.

union all operator select all values(records) from both table.

select * from order1
union all
select * from order2;


select ord_id, cust_id from order1
union all 
select ord_id ,cust_id from order2

=====================================================================================================================================
Leave a Comment