What Are set operators in SQL server and how we can learn

Опубликовано: 22 September 2026
на канале: VLR Training
160
2

#sql #sqlserver #setoperations

👉 Please Join Our Vlrtraining WhatsApp Group
https://www.vlrtraining.com/VlrTraini...
👉 Please join our Telegram Group
https://t.me/sqlvlrtraining
👉 Chat with us in WhatsApp
Venkat: https://wa.me/919059868766
Mohan: https://wa.me/919492228043
Ramesh: https://wa.me/919985269518

What Are set operators in sql server and how we can learn Contact
Set Operators
► Set operators are combines the 2 or more query result sets and
then produces a single result set based on the operator.
► SQL supports few Set operations to be performed on table data.
These are used to get meaningful results from data, under
different special conditions.

Conditions:
→ Number of columns & Order of the columns should be same with
in the both queries.
→ These columns data types should be compatible



Operator Returns
UNION Combine two or more result sets into a single set, without duplicates.

UNION ALL Combine two or more result sets into a single set, including all duplicates.

INTERSECT Takes the data from both result sets which are in common.

EXCEPT Takes the data from first result set, but not the second (i.e. no matching to each other)

CREATE TABLE vlrstudents1(
Name VARCHAR(15),
course VARCHAR(15),
Salary money )

CREATE TABLE vlrstudents2(
Name VARCHAR(15),
course VARCHAR(15),
Salary money )


INSERT INTO vlrstudents1 VALUES('Venkat','Python',30000);
INSERT INTO vlrstudents1 VALUES('Nani','Java',40000);
INSERT INTO vlrstudents1 VALUES('lakshman','PowerBi',50000);
INSERT INTO vlrstudents1 VALUES('Praveen','Python',30000);
INSERT INTO vlrstudents2 VALUES('vijay','Pega',230000);
INSERT INTO vlrstudents2 VALUES('Venkat','Python',30000);
INSERT INTO vlrstudents2 VALUES('naresh','Python',44000);
INSERT INTO vlrstudents2 VALUES('Mounika','PowerBi',330000);
INSERT INTO vlrstudents2 VALUES('lakshman','PowerBi',50000);


select * from vlrstudents1 UNION select * from vlrstudents2
select * from vlrstudents1 UNION ALL select * from vlrstudents2
select * from vlrstudents1 INTERSECT select * from vlrstudents2
select * from vlrstudents1 EXCEPT select * from vlrstudents2
drop table vlrstudents1
drop table vlrstudents2


Set operators are used to mix effects from or greater SELECT statements. They integrate the identical sort of information from or greater tables. This seems much like SQL joins even though there's a difference. SQL joins are used to mix columns while Set operators are used to sign up for rows from more than one SELECT queries
Set Operations encompass Set Union, Set Intersection, Set Difference, Complement of Set, and Cartesian Product.
There are 4 major set operations which encompass set union, set intersection, set complement, and set difference
The set operations are accomplished on or greater units to achieve a mixture of factors as in keeping with the operation accomplished on them. In a hard and fast theory, there are 3 principal varieties of operations accomplished on units, such as: Union of units (∪) Intersection of units (∩)
Subscribe to our Channel https://goo.gl/G3cB5Q






Like us on Facebook page VLR Training
  / vlrtraininghyderabad  
Follow us on Twitter
  / vlrtrainingkphb  
linked in
  / vlr-training