UNION
1.Combines the results of two or more SELECT Statements.
2.removing duplicate rows.
3.sort all the elements in the results table
4.Union is slower than Union All
Select * from Table1 UNION Select * from Table2
UNION ALL
1.Combines the results of two or more SELECT statements.
2.It including duplicate rows.
3.doesn't sort the data
4.It is faster than Union
Select * from Table1 UNION ALL Select * from Table2
Rules
1.The number of columns in the SELECT statement on which you want to apply the SQL set operators must be the same.
2.The order of columns must be in the same order.
3.The selected columns must have the same data type.
4.If you want to order/sort the results, the ORDER BY clause must go at the end of the last query. You can't add ORDER BY inside each SELECT query before the set operators.
0 Comments
Thanks for your message.