- The number and the order of the columns must be the same in all queries.
- The data types must be compatible.
{ query_specification }
INTERSECT
{ query_specification }
In this article, we are going to use the following table for the examples:-
CREATE TABLE [dbo]. [Employee](
[Empid] [Int] IDENTITY (1, 1) NOT NULL Primary key,
[EmpNumber] [nvarchar](50) NOT NULL,
[EmpFirstName] [nvarchar](150) NOT NULL,
[EmpLAStName] [nvarchar](150) NULL,
[EmpEmail] [nvarchar](150) NULL,
[Salary] [int] NULL
)
We insert following data into the above tables:-
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A001′,’Vivek’,’Johari’,’samir@abcmail.com’,200000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A002′,’Amit’,’Kumar’,’amit@abcmail.com’,100000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A003′,’Neha’,’Sharma’,’neha@abcmail.com’,300000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A004′,’Chandra’,’Singh’,’vivek@abcmail.com’,320000)
Insert Into Employee (EmpNumber,EmpFirstName,EmpLAStName,EmpEmail,salary)
Values(‘A005′,’Avinash’, ‘Dubey’,’avinash@abcmail.com’,250000)
Example
Select Empnumber from employee where salary>200000
A003
A004
A005
Select Empnumber from employee where salary between 100000 and 320000
A001
A002
A003
A004
A005
Now if we use Intersection command between these queries, we get the following result.
Select Empnumber from employee where salary>200000
INTERSECT
Select Empnumber from employee where salary between 100000 and 320000
Result
A003
A004
A005
Pingback: Creative Agency in Orlando
Pingback: Dentists in Reno
Pingback: Dentist in Dallas Texas
Pingback: Torch search onion
Pingback: สินเชื่อ ชัยภูมิ
Pingback: engagement rings
Pingback: โกงชักดาบ
Pingback: Pre-Market Stocks Gold Silver Price Update Today New Futures MKT for Gold
Pingback: https://internetnews.net.pl/wybierz-odpowiednie-spinki-koszuli-lub-garnituru/
Pingback: Dentist in Victoria texas
Pingback: Dream Market
Pingback: Darknet Empire Market
Pingback: w88
Pingback: Digital Income System
Pingback: ratucapsa
Pingback: santali video gana song
Pingback: www.senangpokerq.site
Pingback: elang qq
Pingback: www.1lapakqq.site
Pingback: Eddie Frenay
Pingback: Repo Expert Predicts Markets To Crash by Year End
Pingback: qiuqiu99
Pingback: raja capsa
Pingback: mainqq
Pingback: social
Pingback: truck tailgate vinyl graphics
Pingback: celebs nsfw
Pingback: thevelocity-grp.com
Pingback: engagement selfie frame
Pingback: duratrans printing
Pingback: fowling board decals