E Computer Notes - Using SET Operator
E Computer Notes - Using SET Operator
Objectives
After completing this lesson, you should be able to do the following: Describe SET operators Use a SET operator to combine multiple queries into a single query Control the order of rows returned
UNION/UNION ALL
A B
INTERSECT
A B
MINUS
current employees JOB_HISTORY: Records the details of the start date and end date of the former job, and the job identification number and department when an employee switches jobs
The UNION operator returns results from both queries after eliminating duplications.
The UNION ALL operator returns results from both queries, including all duplications.
http://ecomputernotes.com
http://ecomputernotes.com
http://ecomputernotes.com
http://ecomputernotes.com
Column names from the first query appear in the The output is sorted in ascending order by default
except in UNION ALL.
http://ecomputernotes.com
http://ecomputernotes.com
SELECT employee_id, job_id,salary FROM employees UNION SELECT employee_id, job_id,0 FROM job_history;
http://ecomputernotes.com