SQL UNION ALL
SQL UNION ALL is combine the results of two queries together without filter out the same value(no distinct behavior).
The difference between UNION ALL and UNION is UNION only selects distinct values and UNION ALL selects all values.
Syntax - UNION ALL
(SQL Statement 1)
UNION ALL
(SQL Statement 2)
Below is example for SQL UNION
Company
Sales($)
Website
Sql Traniner 2500 http://www.sqltutorials.blogspot.com
BeautyCentury 3000 http://beautycentury.blogspot.com
TravelYourself 2800 http://travelyourself.blogspot.com
Table1
Sales
Website
2900 http://www.sqltutorials.blogspot.com
3000 http://beautycentury.blogspot.com
2800 http://travelyourself.blogspot.com
Table2
SQL UNION ALL Statement
SELECT Sales FROM TABLE1
UNION ALL
SELECT Sales FROM TABLE2
Result
Sales
2500
3000
2800
2900
3000
2800
Monday, March 22
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment