Professional Documents
Culture Documents
Mark Angelo C. Vacal It3A Activity#1 - Joins: Create Database
Mark Angelo C. Vacal It3A Activity#1 - Joins: Create Database
Vacal
IT3A
ACTIVITY#1 – JOINS
4. USING UNIONS
QUERY
UNION
DISTINCT
SELECT First_Name
FROM emp
UNION
SELECT Dept_Name
FROM emp;
If some First name have the same Department Name, each Department Name will only be
listed once, because UNION selects only distinct values
UNION DISTINCT
As you can see First name and Last Name have the same Department Name and ID each
Department Name And ID will only be listed once, because UNION selects only distinct
values.
UNION ALL
SELECT First_Name
FROM emp
UNION ALL
SELECT Dept_Name
FROM emp;
UNION ALL command combines the result set of two or more SELECT statements (allows
duplicate values).
UNION ALL
The UNION ALL command aggregates the output of two or more SELECT queries into a single
data structure (allows duplicate values).