UNION only selects distinct values. |
Syntax |
In order to perform UNION the column in SQL statement1 must match column in SQL statement2 |
SELECT * FROM employees |
ID | Last Name | First Name | Title |
1 | Johnson | David | crew |
2 | Hively | Jessica | crew |
9 | Hicks | Freddy | crew |
10 | Harris | Joel | crew |
11 | Davis | Julie | manager |
101 | Yazzow | Jim | crew |
102 | Anderson | Craig | crew |
103 | Carlson | Kevin | crew |
104 | Maines | Brad | crew |
UNION ALL selects all rows from each table and combines them into a single table. |
SELECT * FROM employees |
ID | Last Name | First Name | Title |
1 | Johnson | David | crew |
2 | Hively | Jessica | crew |
9 | Hicks | Freddy | crew |
10 | Harris | Joel | crew |
11 | Davis | Julie | manager |
101 | Yazzow | Jim | crew |
102 | Anderson | Craig | crew |
103 | Carlson | Kevin | crew |
11 | Davis | Julie | manager |
104 | Maines | Brad | crew |
No comments:
Post a Comment