0% found this document useful (0 votes)
0 views

19 SQL – Set Operators in SQL

The document explains set operators used in SQL to combine results from multiple SELECT statements. It details four operators: UNION (removes duplicates), UNION ALL (keeps duplicates), INTERSECT (returns common results), and EXCEPT (returns results in the first set but not in the second). Each operator is accompanied by a description and an example for clarity.

Uploaded by

itmanarif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

19 SQL – Set Operators in SQL

The document explains set operators used in SQL to combine results from multiple SELECT statements. It details four operators: UNION (removes duplicates), UNION ALL (keeps duplicates), INTERSECT (returns common results), and EXCEPT (returns results in the first set but not in the second). Each operator is accompanied by a description and an example for clarity.

Uploaded by

itmanarif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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;

You might also like