Day – 19 :
Set Operators
Course created by Satish Dhawale | www.skillcourse.in
Combine the results of two or more SELECT statements
Operator Description
UNION Combines results, removes duplicates
UNION ALL Combines results, keeps duplicates
INTERSECT Returns common results
EXCEPT Returns results in first, not second
Combine the results of two or more SELECT statements
Operator Description Example Result
SELECT student_name, course FROM
students_2023
Combines results, removes
UNION UNION Unique combined results
duplicates
SELECT student_name, course FROM
students_2024;
SELECT student_name, course FROM
students_2023
UNION ALL Combines results, keeps duplicates UNION ALL All combined results
SELECT student_name, course FROM
students_2024;
SELECT student_name, course FROM
students_2023
INTERSECT Returns common results INTERSECT Common results only
SELECT student_name, course FROM
students_2024;
SELECT student_name, course FROM
students_2023
EXCEPT Returns results in first, not second EXCEPT Results only in first
SELECT student_name, course FROM
students_2024;